We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

jimbob1977's avatar
jimbob1977
Helpful | Level 6
6 years ago
Solved

Automate DropBox Using Script

Hi

I am working on a project that requires sharing of video files to different recipients.

I therefor need to use script to...

- Upload a file from my local folder

- Share the file + get download link

- Email the link to the client

 

I can do parts 1 and 3 - is there any documentation or advice on how to automate the share and link retreival

  • Hi jimbob1977,

    If you run Linux, the best place of your question isn't API section. You can get link to arbitrary file in the Dropbox folder using CLI. Take a look on "sharelink" command. :wink:

    Unfortunately, CLI is available only on Linux, so if you run something else, this advice isn't for you (or at least, if you don't plane switch to Linux).

    Hope this helps to some extent.

5 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    To create a shared link via the Dropbox API, you should use the /2/sharing/create_shared_link_with_settings endpoint:

     

    https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings

     

    That allows you to specify a file or folder and returns a shared link for it. You can then use the link as desired, e.g., to send it to someone. They can then download the linked file or folder from it.

     

    Or, to retrieve already existing shared links, you can use /2/sharing/list_shared_links:

     

    https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links

     

    By the way, those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible:

     

    https://www.dropbox.com/developers/documentation

     

    Those have corresponding native methods for the HTTPS endpoints. 

  • jimbob1977's avatar
    jimbob1977
    Helpful | Level 6
    6 years ago

    Hi Greg

    Thanks for your help.  I've been looking through the API Descriptions and experimented with the API Explorer.

    Think I'm missing the p[oint somewhere???

     

    To upload a file I am using...

    curl -X POST https://content.dropboxapi.com/2/files/upload \
      --header 'Authorization: Bearer MYAUTHCODE' \
      --header 'Content-Type: application/octet-stream' \
      --header 'Dropbox-API-Arg: {"path":"/MyLocalFolder/Clown.jpeg"}' 

    When I run this I get the error...

     

    {"error_summary": "path/conflict/file/...", "error": {".tag": "path", "reason": {".tag": "conflict", "conflict": {".tag": "file"}}, "upload_session_id": "AAAAAAAAA_Hm7Dp23cYtfg"}

     

    The file doesnt exist on my dropbox and is less than 150MB

     

    Any ideas as to where I'm going wrong??

  • jimbob1977's avatar
    jimbob1977
    Helpful | Level 6
    6 years ago

    OK - So I've seen the error of my ways.

    To clarify...

    The path - is the path withinmy dropbox Apps folder where the file will be located - Correct???

     

    Stupid Question - how does it know which file to upload ?? or isd it as simple as it finds a file by same name on local drive?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    The "path" parameter you specify is the path in the Dropbox account where you want to put the uploaded file. If your app uses the "app folder" permission, that path will be used relative to the app folder.

     

    The "path/conflict/file" error indicates that there's already something at the specified path, so the upload couldn't complete. Check out the /2/files/upload "mode" parameter documentation for information on configuring what happens in that case.

     

    The "path" parameter value is only used to specifying where to upload the file in Dropbox. It is not used to find or specify what data to upload. The data for the file upload is whatever you send in the request body. When using curl on the command line like this, you can specify that data via curl's "--data-binary" option. There's an example of doing so included in the /2/files/upload documentation

     

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    6 years ago

    Hi jimbob1977,

    If you run Linux, the best place of your question isn't API section. You can get link to arbitrary file in the Dropbox folder using CLI. Take a look on "sharelink" command. :wink:

    Unfortunately, CLI is available only on Linux, so if you run something else, this advice isn't for you (or at least, if you don't plane switch to Linux).

    Hope this helps to some extent.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers814 PostsLatest Activity: 11 hours ago
274 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!