I am using the File Uploader component to upload files.
I want to store data about the uploaded files in a column of a table. Based on reading documentation, I chose the JSON column type to store the filename, full URL, and the file path without the filename.
What is the proper way to take the data from the UPLOADED FILES object and put it into a JSON column?
Thanks.
To work with files, use the Backendless → File API.
Also i would recommend for structured data using just a table with fields, where one of the column may be a File Reference type.
Oleg. Thank you for your response, but let me clarify my question.
-
I want to store information about multiple files. The FILE REFERENCE column type only stores a string for one file containing the URL.
-
I want to store information about multiple files, and I want to store more than just the URL.
Is the JSON column type the best choice? I see no other.
What is the best practice Codeless code for storing JSON data in a JSON column?
- I don’t need to read the files, so the Files API is not the appropriate solution.
Thanks.
That is why i said that for structured data the table is more appropriate. JSON column is just a part of one record (one column) in the db. It gives you possibility to store data without a structure, but it is not a DB and it lack a lot of features for selecting, filtering, grouping.
Where are the uploaded files stored? Backendless Files?
You may create a custom object, e.g. FileMetaInfo with fields (name, size, path, etc.) and store it in a table. Each record will represent information about one file. Group of records may have relations to other tables.
If to talk about the JSON column, it is just a column and you can work with it like with other tables/columns using Data API.
You just need to keep in mind that this is a complex data type that supports additional features.
In order to understand how it works and how it integrated in Data API you may read
https://backendless.com/docs/js/data_json_overview.html
JsonPath queries may be tested in REST console.
Thank you again, but my question is still:
What is the best practice in CODELESS to populate a JSON column with a JSON document?
In PHP, I would use a function to convert an array or an object to JSON. Codeless does not have such a function. If you can, please provide a Codeless example.
Thanks.
Interesting chaining of conversions. I would not have expected the Convert to Text block to accept an array. Thanks.
“Convert to text” can take anything (primitive values, objects, arrays/lists).