Cant link a file column to file in files collection

This forum contains topics that were moved from Get Satisfaction
Asif Ansari
Posts: 0
Joined: Tue Jul 07, 2015 4:00 am

Cant link a file column to file in files collection

Post by Asif Ansari »

Hello, I am able to successfully upload an image to the database using the tutorials given. The issue is when I want to link that image to the user profile. The structure I have starts with the users collection that has a pointer to a Customers collection. The customers collection has a column of type file which I am expecting to store the main profile pic to. I can manually update that column to point to the file I just uploaded to the files collection, but I don't know how to do this programmatically. I have gone through all the tutorials and can't find out how to do this. On success of the file upload, the response returns a filename and originalfilename, but when trying to map that to a variable, it fails and doesn't continue to process further commands. Any help is much appreciated.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Cant link a file column to file in files collection

Post by Evgene Karachevtsev »

Hello Asif,

Please check this post, hope it will be useful for you:
https://getsatisfaction.com/apperyio/...

Asif Ansari
Posts: 0
Joined: Tue Jul 07, 2015 4:00 am

Cant link a file column to file in files collection

Post by Asif Ansari »

Evgene,

Thanks, this actually did help and I was able to store a string representation of the image base 64 in the collection. Do you have any information on how to actually store something with a column of type file???

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Cant link a file column to file in files collection

Post by Alena Prykhodko »

Dear Asif,

Please read this brief explanation https://devcenter.appery.io/documenta...

Asif Ansari
Posts: 0
Joined: Tue Jul 07, 2015 4:00 am

Cant link a file column to file in files collection

Post by Asif Ansari »

Alena, thanks I appreciate it, I have seen this link numerous times. I know how to store the file using the media manager through the interface you have available. I am more interested in learning how I do it programattically. Do you have an example where the user loads a specific file to the media manager, and then that file is referenced back to the file column of a different collection?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Cant link a file column to file in files collection

Post by Yurii Orishchuk »

Hi Asif,

Here is a common plan to upload file and store it in "file" type collection field.

1 Upload file and fetch "fileName" value from it response. Store it in some storage.
2 In update/create service you need to link value from storage(1st step) to file-field "fileName" request parameter.
Details: http://prntscr.com/7xekdv/direct

So basically you need to pass received from upload service fileName to fileName request parameter in update service.

Regards.

Asif Ansari
Posts: 0
Joined: Tue Jul 07, 2015 4:00 am

Cant link a file column to file in files collection

Post by Asif Ansari »

Thanks Yurii, we're getting closer. The problem is when I upload an image to the file collection following this tutorial... https://devcenter.appery.io/tutorials... . It does not return a filename to me anywhere. Do you have steps to show me how I use the service with the mapping so it returns the filename? Thanks.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Cant link a file column to file in files collection

Post by Yurii Orishchuk »

Hi Asif,

Yes if you use this "upload" service - your service responds with these parameters.

Please check upload service if you don't have such parameters you need add them manually.

Details: http://prntscr.com/7yl3xv/direct

Regards.

Asif Ansari
Posts: 0
Joined: Tue Jul 07, 2015 4:00 am

Cant link a file column to file in files collection

Post by Asif Ansari »

Yurii, thank you so much for this reply. I see where the problem was. It was in the creation of the upload service that is created automatically. The response body was not in the same format as in your screenshot. Once I changed it, I started seeing the results. It looks like you may have a bug in the service creation and how the response is generated. Thanks again.

Post Reply