Hey @Paolo_Proxy,
When you make the first POST call to https://api.losant.com/applications/APPLICATION_ID/files
with a post body, like the following:
{
"name": "file.csv",
"type": "file",
"parentDirectory": "/",
"fileSize": 500,
"contentType": "text/csv"
}
where name is the name of the file you would like to use, the parentDirectory is the directory. In this example “/” would be the root directory but you could do “/foo/bar”, and your file would appear in the directory bar under the directory foo e.g. /foo/bar/file.csv. If this request is successful you should be able to see the directory and the file in your application via the UI. The file will say the status is “pending” since no upload has been attempted yet.
if the request is successful you would get a response of a file object as seen in this example or like the following:
{
"id": "575ec8687ae143cd83dc4a96",
"applicationId": "575ec8687ae143cd83dc4a97",
"creationDate": "2016-06-13T04:00:00.000Z",
"lastUpdated": "2016-06-13T04:00:00.000Z",
"authorId": "575ed70c7ae143cd83dc4aa9",
"authorType": "user",
"status": "pending",
"name": "file.csv",
"type": "file",
"parentDirectory": "/",
"fileSize": 500,
"contentType": "text/csv"
}
In this example the “id” field would be the FILEID you use in the second post.
So based on this example if you wanted to use the post upload endpoint.
curl -H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-F file=@localfilename' \
https://api.losant.com/applications/575ec8687ae143cd83dc4a97/file/575ec8687ae143cd83dc4a96/upload
And if that is successful, then in the UI the status of the files will turn to completed. You will have access to a download link to share or redownload the file to confirm the contents are what you expect.
I hope this helps. Let me know if you need any further explanation.
Best,
Erin