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
alicera
4 years agoExplorer | Level 3
check download file
If I get a link for dropbox and I use the 'wget' to download it.
How to check it if download successfully?
- 3 years ago
alicera In addition to the method Здравко helpfully provided, you could use the /2/sharing/get_shared_link_metadata Dropbox API endpoint to retrieve the metadata for a shared link, or an error if the shared link is invalid.
Greg-DB
Dropbox Staff
You can check the HTTP status code of the response to see what the result is. For example, a 200 indicates success.
alicera
4 years agoExplorer | Level 3
wget -nc dropbox_url
It will download other file.
- Greg-DB4 years agoDropbox Staff
I'm not sure I understand your latest message. Do you have a question a I can help with?
- Здравко4 years agoLegendary | Level 20
Hi alicera,
For any kind of error that might come up on command line, you can check the retrieved result. For most commands (including 'wget'), success is denoted by zero. Any different exit status means that something happens considered as a error. File not found (HTTP status 404) gets transformed to server issued an error response - exit status 8, for example.
alicera wrote:wget -nc dropbox_url
It will download other file.
No, no another file will get downloaded, while 'dropbox_url' keeps the same. Keep in mind that in such a case existing file is NOT considered error! That's why you're getting success and probably got confused. 🙂 To force existing file consideration as an error, you can use something like:
wget -nc -O filename.ext dropbox_url
Where 'filename.ext' is the desirable file name (possibly path prepended). Now (after explicit destination pointing) a try downloading already existing file (probably downloaded before) will result in general error (exit status 1, no more 0), which you can check. 😉
Hope this helps.
- alicera3 years agoExplorer | Level 3
https://unix.stackexchange.com/questions/474805/verify-if-a-url-exists
I use the method and give error dropbox link,
it is return link exist
- Здравко3 years agoLegendary | Level 20
Ahh... alicera, now I see what you mean.
You want to check not for error in transfer process or error because of existing (already) file, but link validity.
It's not so trivial cosa Dropbox links are dynamically generated and even when no real file exists link point to error message (as a content, it's still valid). That's why you are getting "200 OK" for both valid and invalid link (the error message is valid 🤫). But there is a workaround. 😉 When some link is invalid, error message gets back immediately. If your link points to real file, redirect is performed to the pointed file. You can exploit this. 'wget' perform redirects by default and that's why always succeeds. If you disable redirects, a "strange" situation will happen: valid links will result in error (can't redirect), but invalid will succeed (redirect doesn't needed). So, inverting the check logic is going let you distinguish valid to invalid links. 🙂 Use something like following template:
wget --method=HEAD -q --max-redirect 0 <some Dropbox shared link> echo $?
The above just print resulting code (currently 0 for invalid link - inverted logic). You can check it in conditional expression too, of course.
Hope this helps.
About Discuss Dropbox Developer & API
Make connections with other developers
797 PostsLatest Activity: 5 days agoIf 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!