You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Amicao's avatar
Amicao
Explorer | Level 3
3 years ago

How to get a temporary link from file that was uploaded via Dropbox API

Hello, good afternoon for all, i am here again for other problem related to get temporary link from file.

 

I made a Laravel system using the Dropbox API to get a file from user, upload it and later, get a access for this file and delete it if necessary. The problem is that upload the file and Dropbox change the file name to a own Dropbox hash system. And it difficult me to get the temporary link automatically via Laravel, because my system don't know now my file name automatically. Does exist a way to me disable the file name name alteration? Or does exists other way to do this feature more simplest? 

 

I will be gratefull


  • Amicao wrote:

    ... a file from user, upload it and later, get a access for this file and delete it if necessary. The problem is that upload the file and Dropbox change the file name to a own Dropbox hash system. ...


    Hi Amicao,

    It's good idea to you share some piece of your algorithm able to reproduce the issue. Generally Dropbox API doesn't change file name if there is no other file already existing with the same name on the same place (path). Even when such file exist it can be updated, depending on your intention, upload can fails, or automatically rename it (whatever appropriate).

     


    Amicao wrote:

    ... And it difficult me to get the temporary link automatically via Laravel, because my system don't know now my file name automatically. ...


    On successful file upload (either with changed or intended name) actual name gets as a part of the API access point result (take a look on /2/files/upload Returns section, for example). So you (your system) definitely know how your file gets named and the file id too. Using this you can pass it to the 2/files/get_temporary_link call.

     


    Amicao wrote:

    ... Does exist a way to me disable the file name name alteration? ...


    Take a look on "mode" parameter for possible alternatives.

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

    Amicao wrote:

    ... a file from user, upload it and later, get a access for this file and delete it if necessary. The problem is that upload the file and Dropbox change the file name to a own Dropbox hash system. ...


    Hi Amicao,

    It's good idea to you share some piece of your algorithm able to reproduce the issue. Generally Dropbox API doesn't change file name if there is no other file already existing with the same name on the same place (path). Even when such file exist it can be updated, depending on your intention, upload can fails, or automatically rename it (whatever appropriate).

     


    Amicao wrote:

    ... And it difficult me to get the temporary link automatically via Laravel, because my system don't know now my file name automatically. ...


    On successful file upload (either with changed or intended name) actual name gets as a part of the API access point result (take a look on /2/files/upload Returns section, for example). So you (your system) definitely know how your file gets named and the file id too. Using this you can pass it to the 2/files/get_temporary_link call.

     


    Amicao wrote:

    ... Does exist a way to me disable the file name name alteration? ...


    Take a look on "mode" parameter for possible alternatives.

    • Amicao's avatar
      Amicao
      Explorer | Level 3

      I discovered the problem, the Laravel Framework libraries doesn't support more the Dropbox API, because Dropbox had modified your API politics, as well as your upload API and others, so my framework is doing a wrong request to save data passing the filename as filepath parameter and not filename parameter, what is resulting in empty filename, then Dropbox is generating a random name with your hash algorithm.

       

      But now, i would like to know how I make a upload request without passing the filepath as parameter, but yes the file or binary object from file in Curl request. Because in a framework server side in server-client system, its not capable to get the filepath once this is from client and not from server, and the application sever doesnt allow to upload file in your container temporally, because i am trying to use the Dropbox API.

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

        Hi Amicao,

        I'm glad that my previous post helped you to some extent.

        About API changes: If you don't take in mind API state very log ago, API calls (most of them, including upload/download, you are interested in) are not changed or not significantly, at least. The only non back compatible change, recently released (started 2-3 years ago) is drop of long time access token (new can't be issued, despite existing can be used still) and replacement with refresh token for long term use. Everything else is back compatible, at least, if not the same.


        Amicao wrote:

        I discovered the problem, the Laravel Framework libraries doesn't support more the Dropbox API, because Dropbox had modified your API politics, as well as your upload API and others, so my framework is doing a wrong request to save data passing the filename as filepath parameter and not filename parameter, what is resulting in empty filename, then Dropbox is generating a random name with your hash algorithm.

        ...


        I have no any idea what you mean here. 🤔 Do you take in mind some time before roughly 5-10 years ago, or even more? If the provider isn't updated the product (tool you are using) so long, ask there. 🤷

         


        Amicao wrote:

        ...

        But now, i would like to know how I make a upload request without passing the filepath as parameter, but yes the file or binary object from file in Curl request. Because in a framework server side in server-client system, its not capable to get the filepath once this is from client and not from server, and the application sever doesnt allow to upload file in your container temporally, because i am trying to use the Dropbox API.


        You can NOT save any file in Dropbox user space without name! No chance. You must save uploaded content under some name (whatever is it) at the end, at least. Whenever you get a file (either from the server space or in some user upload session), a file name should be ensured and is usually available in one or other way. To be honest, I can't even imagine a situation that client-server system can't ensure available file name. Probably you have done something wrong there. Fix it, if really need. If I have to bet, this name is available already somewhere, just find its exact place out.

        About "temporally" upload space: You can use upload session (/2/files/upload_session/start), where the name/path isn't need at session start and when continue upload in the same session (/2/files/upload_session/append_v2) if need. In such a way you can delay set the name, but can NOT avoid it! At finalization (/2/files/upload_session/finish), you have to pass the place (name and path) where this file have to reside in at the end. That's it.

        As a workaround you can use some stable and predictable algorithm (in dependence what are objectives) to set a temporary name, if so much needed (I don't believe it is).

        Good luck.

         

        ADD: Actually using PHP curl calls you can do whatever you want (even more than the officially supported SDKs can) to large extent! 😉

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API

Make connections with other developers

797 PostsLatest Activity: 8 hours ago
199 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!