We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

julio_diniz_perdigao's avatar
julio_diniz_perdigao
Explorer | Level 3
10 months ago

Upload to a specific file id

Hi!

Google Drive has an method that we can create the file ID first, before start upload.

 

Does Dropbox has somenthing similar?

 

My point is, to get file metadata, specially file size, after upload is done via getTemporaryUploadLink.

 

Knowing the file ID before, I can prevent broken response between the client-side upload and my back-end call.

 

Now, I am doing:

1 - create upload link with getTemporaryUploadLink (back-end)

2 - upload the file from client-side with the link passed by back-end

3 - when upload is done, send to the back-end the file ID

 

But I am affraid in step 3, some connections problem and not be able to pass the file ID to my back-end.

 

Thanks!


  • julio_diniz_perdigao wrote:

    ...

    But I am affraid in step 3, some connections problem and not be able to pass the file ID to my back-end.

    ...


    Hi julio_diniz_perdigao,

    You don't need to pass the id in step 3. Tracing the changes in target directory would give you exact moment of file upload and its id as soon as upload finishes without additional communication between client and server side. 😉

    Hope this helps.

  • julio_diniz_perdigao As Здравко suggested, you don't necessarily need the file ID and can instead monitor for changes. Check out the Detecting Changes Guide for information on how to do so.

     

    If that isn't sufficient for your use case though, you could first upload a placeholder (e.g., a zero byte file, or something else of your choosing) from the back-end to get the file ID for that, and then configure the temporary upload link to overwrite that placeholder file.

    • julio_diniz_perdigao's avatar
      julio_diniz_perdigao
      Explorer | Level 3

      Hi Greg-DB !

      Good tip! Do you know which process is more faster? I mean, get file metada from a file ID or file path? My guess is the file ID, when have a lot of files.

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

        julio_diniz_perdigao There's no particular guarantee on whether using a file ID or a file path to retrieve a file's metadata would be faster. (There may also be other variables that would affect that anyway.)