I generated a public file request in Dropbox and would like to write some javascript code to programmatically upload a file which is generated on the flow (e.g. var myJsonString = JSON.stringify(myArray)
) to the public folder.
As an example, I created this public folder:
Since this is your Dropbox file request, you can use the standard Dropbox API to upload a file to this folder using an access token. There's no API to anonymously upload to some one else's file request folder as a public user would via the webpage, but because this is your folder, you can also make an API proxy to do this if you wanted such an API.
I've tested uploading to a File request folder with the API and it works fine.
Listing File Requests
You can retrieve a list of your file requests here using the 2/file_requests/list
RPC API endpoint.
POST https://api.dropboxapi.com/2/file_requests/list
Like any Dropbox folder, you can upload to a file request via its file path specified by the destination
property shown below.
{
"file_requests":[
{
"id":"0123456789abcdefghi",
"url":"https://www.dropbox.com/request/0123456789abcdefghi",
"title":"My File Request",
"destination":"/File requests/My File Request",
"created":"2018-06-08T15:17:45Z",
"is_open":true,
"file_count":0
}
]
}
Uploading Files
Once you have your specific file request folder, you can upload to it using the appropriate full path, e.g. /File requests/My File Request
and use it in a standard RPC File Upload API call - /2/files/upload
.
POST https://content.dropboxapi.com/2/files/upload
You will need to specify a path like /File requests/My File Request/My File.png
via the Dropbox-API-Arg
header as specified in the API Reference:
Web UI
Here's a screenshot of the public request root folder in the web UI home folder. The public request folder may change so it's a good idea to check the /2/file_requests/list
API call specified above.
All File Request APIs
Here's a list of the Dropbox File Request specific APIs. As mentioned, you can use standard APIs against these folders and files as well.
2/file_requests/create
- Creates a file request for this user.2/file_requests/get
- Returns the specified file request.2/file_requests/list
- Returns a list of file requests owned by this user. For apps with the app folder permission, this will only return file requests with destinations in the app folder.2/file_requests/update
- Update a file request.