We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
vegard
9 years agoExplorer | Level 3
Streaming Non-Shared Music (Javascript)
I want to write a simple javascript-based (frontend only) dropbox music player. Just a dropbox file explorer, playlist and audio controls -- very basic for when I want to play some music without syncing the files locally.
I have experimented a bit, and can create a temporary file link (filesGetTemporaryLink) and play it with Audio object.
This works, but I wonder if there is a better way? It seems a temporary link is a public (non-authenticated) link to the file. I guess it is a very minor security risk. I don't know if Dropbox likes/allows frequent temporary link creation. Is it possible to get an authenticated link?
Thanks for the help. Sorry, I am a bit new to web/javascript/dropbox-api so I might be missing the obvious.
2 Replies
- Greg-DB9 years ago
Dropbox Community Moderator
The Dropbox API doesn't offer an alternative for this, but I'll pass this along as a feature request. The temporary links contain a randomly generated token though, so they should be effectively impossible to guess.
For reference, the way to directly access file content in an authenticated fashion is to use filesDownload:
https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor
That may not work for your use case, as it doesn't give you a URL you can pass to a media player. Depending on the media player though, making a local blob URL as shown here might work for you:
https://github.com/dropbox/dropbox-sdk-js/blob/a88a138c0c3260c3537f30f94b003c1cf64f2fbd/examples/javascript/download/index.html#L51 - vegard9 years agoExplorer | Level 3
Thanks Greg!
With filesDownload, it seems it is possible to use the audio object with the return of URL.createObjectURL(blob).
I guess this is more secure, but it is definitly faster to create the temporary link and stream that.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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, Facebook or Instagram.
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!