admin管理员组

文章数量:1336660

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:

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:

https://www.dropbox./request/3gnn9m16eVCwxazuQIOF

Share Improve this question edited Jun 6, 2018 at 5:08 Grokify 16.4k8 gold badges69 silver badges92 bronze badges asked Jun 2, 2018 at 11:24 matmat 2,6375 gold badges37 silver badges77 bronze badges 2
  • [Cross-linking for reference: dropboxforum./t5/API-Support-Feedback/… ] – Greg Commented Jun 4, 2018 at 15:02
  • I've updated my answer below to to indicate there's no problem uploading to a public folder via the standard Dropbox REST API. Just use the list_folder API to retrieve the path for your folder and the upload API to upload your files. – Grokify Commented Jun 8, 2018 at 15:51
Add a ment  | 

1 Answer 1

Reset to default 7 +50

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./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./request/0123456789abcdefghi",
      "title":"My File Request",
      "destination":"/File requests/My File Request",
      "created":"2018-06-08T15:17:45Z",
      "is_open":true,
      "file_count":0
    }
  ]
}
  • Ref: https://www.dropbox./developers/documentation/http/documentation#file_requests-list

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./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:

  • Ref: https://www.dropbox./developers/documentation/http/documentation#files-upload

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.

本文标签: Dropbox upload file to public file request with JavaScriptStack Overflow