I save media files in json object. And I add multiple json to an array. That array is a field of parseObject. But when I save object, File url is hardcoded.
This is an example object.
"media": [{
"type": "image",
"width": 591,
"height": 1280,
"media": {
"__type": "File",
"name": "fadee2cc345b9e6e9f03490d2f5f018d_F8Oxm7yQVE.jpeg",
"url": "This is hardcoded url. And seems like file adapter has no effect on it"
},
"thumbnail": {
"__type": "File",
"name": "944f9eeb9974d290febcafa0a6dc6400_F8Oxm7yQVE.jpeg",
"url": "This is hardcoded url. And seems like file adapter has no effect on it"
}
}]
Parse files saved the first URL they have got. And When looked the schema ıt just says media field is array but nothing more. Parse schema doesnt show whats inside of array.
How can I solve this? I want to save files like its a filed of parse object. When file is field of the parse Object, Parse only saves file name and fill the url that returned from files adapter? How can I do this?
Its my own object in my database. But ıf you ask me what platform I used to see, I’m using mongodb compass.
Here is How I created it:
for(var i = 0; i < mediaList.length; i++){
//...other logic
var mainmedia = new Parse.File(user.id, { base64: mediaData },mimeInfo.mime);
var thumbfile = new Parse.File(user.id, { base64: thumbnail },mimeInfo.mime);
var item = {"type":"image","width":ratiow,"height":ratioh,"media":mainmedia,"thumbnail":thumbfile};
itemList.push(item);
}
post.set("media",itemList);
I believe it should work properly. I’ve seen the dashboard messing up file fields before. Do you mind to do one more test again? Try to save the file and check the object directly in MongoDB without opening the dashboard.
Sorry. I’m a noob. What does “opening a PR with test case” mean? I know how to open a PR. But with failing test case? Do you want me to write a test case in spec.js file ? And create a pull request with that branch?
Any example will be welcome. Sorry if this is a noob question.
Something like this or this or this. There are some other tests related to that. Note there are tests for files in arrays, in objects and also in objects inside objects, but not objects inside arrays.
Oh i understand. But in order to make test fail, base url must be changed. How can we simulate that?
Edit: I created a pull request. But Since I dont know how I can change baseUrl in test file, test case propably will pass. I can push another commit when I learn how to simulate baseUrl change. Or maybe one of the team members push. I allowed members to edit my branch https://github.com/parse-community/parse-server/pull/7124/