We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

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

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.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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

      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

        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?

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

    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 developers

795 PostsLatest Activity: 7 days ago
192 Following

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!