In my app, the users can upload files to a table named “currentUploads”. So I am going to add some columns in my table, but I have a problem.
These are the columns i need to add:
imageFile (this has to be a file - example: file.png)
reportedBy (this has to be an array)
But the problem is, that I can't understand how to fit it correct in the type. What type do I have to choose for them?
I added a screenshot of the types I can choose from.
As far as I know (from my 1 month backendless’s experience) you can not upload a file in an column.
I uploaded the file like this;
Upload file to the Files explorer in backendless and get the file URL (using Asynchronous method of uploading).
In your table (for example User) append the link in imageFile like:
BackendlessUser user = Backendless.UserService.CurrentUser;
and than update the user
Backendless.UserService.update(user, new Asynch.........)
This will save your file url in the Users table in imageFile column.
You can use Picasso library to load the image in imageView
For reportedBy I don’t know how to achieve that since I don’t have much experience with backendless yet…
I’m sure Mark Piller knows how to do that.
You can first save file by calling Backendless.Files.upload(File file, String path) and retrieve saved file url. After that you can save url to file ‘imageFile’ column. For ‘reportedBy’ column you can choose one-to-many relation on Users table and set users who reported this file.
The “reportedBy” is not going to be in the Users table, but in a new table I created named “currentUploads”. What type for array? I want to save multiple strings in the array = the column is going to contain multiple usernames.
To store “arrays” as a single value/property, you can convert it to a JSON array and store as a string.