Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropbox: upload file to public file request with JavaScript

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.com/request/3gnn9m16eVCwxazuQIOF

like image 868
mat Avatar asked Jun 02 '18 11:06

mat


People also ask

Can we upload file using JavaScript?

html file through a browser, the client will be able to upload a file to the server using Ajax and pure JavaScript. A pure JavaScript file uploader simplifies Ajax based interactions with the server.

Can you send someone a Dropbox link to upload files?

You can share these links with anyone, even if they don't have a Dropbox account. If you send a link by email, WhatsApp, Twitter, instant message, or another third-party app.


1 Answers

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
    }
  ]
}
  • Ref: https://www.dropbox.com/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.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:

  • Ref: https://www.dropbox.com/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.

enter image description here

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.
like image 189
Grokify Avatar answered Sep 28 '22 08:09

Grokify