Uploading files
There are number of ways to upload files to a database:
- Files can be uploaded to the database directly from the database dashboard using the Media Manager.
- Files can be uploaded from the app you are creating:
- jQuery Mobile apps:
- Using a ready-to-use plug-in: Upload File to Database.
- A step-by-step tutorial that uses JavaScript code.
- AngularJS apps:
- Using a ready-to-use plug-in: Files Upload.
- jQuery Mobile apps:
To upload a file, send POST request to the following URL:
https://api.appery.io/rest/1/db/files/<fileName>
cURL:
curl -X POST \
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
-H "X-Appery-Session-Token: 6fb9515d-82fd-43b3-9124-f0534dceca8e" \
-H "Content-Type: <contentType>" \
-d "<fileContent>" \
https://api.appery.io/rest/1/db/files/myFile.txt
{
"filename":"c2c638c1-2add-40da-bbd1-e1ff662093ce.myFile.txt",
"fileurl":"https://api.appery.io/rest/1/db/files/534fc8eee4b0790ac5d968fe/c2c638c1-2add-40da-bbd1-e1ff662093ce.myFile.txt"
}
Use --form parameter and multipart/form-data for Content-Type to upload with FormData:
curl -X POST \
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
-H "X-Appery-Session-Token: 6fb9515d-82fd-43b3-9124-f0534dceca8e" \
-H "Content-Type: multipart/form-data" \
--form file=@<filePath> \
https://api.appery.io/rest/1/db/files/myFile.txt