Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello, I tried to stream my videos from dropbox in my site with shared with javascript to create blob source link but there is an issue with cors,
the code
<video id="my-video" class="video-js" controls preload="metadata" width="640" height="264" data-setup="{}"> </video> <script type="text/javascript"> var xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; xhr.onload = function() { var reader = new FileReader(); reader.onloadend = function() { var byteCharacters = atob(reader.result.slice(reader.result.indexOf(',') + 1)); var byteNumbers = new Array(byteCharacters.length); for (var i = 0; i < byteCharacters.length; i++) { byteNumbers[i] = byteCharacters.charCodeAt(i); } var byteArray = new Uint8Array(byteNumbers); var blob = new Blob([byteArray], {type: 'video/ogg'}); var url = URL.createObjectURL(blob); document.getElementById('my-video').src=url; } reader.readAsDataURL(xhr.response); }; xhr.open('GET', 'https://www.dropbox.com/s/0tztdjct8uuwgl5/flowers.mp4?dl=1'); xhr.send(); </script>
What can i do?
The 'www.dropbox.com site' doesn't allow CORS like this.
You can technically make this work using 'dl.dropboxusercontent.com' (e.g., "https://dl.dropboxusercontent.com/s/0tztdjct8uuwgl5/flowers.mp4"), but please note that isn't officially supported.
How can i do that with dropbox api?
You can list existing shared links or create new shared links using the Dropbox API. The Dropbox API only returns the supported version of the links. If you want to use the unsupported versions, you'd have to perform the string modification in your code.
Is there any expected problems if i use unsupported version?
The unsupported form of shared links is subject to change/break without warning.
I can't understand your last comment?
The "dl.dropboxusercontent.com" shared links currently happen to work for this, but I can't promise they will continue to. It may break without warning.
It looks like you're requesting sample code for calling /2/sharing/list_shared_links from PHP. I don't have a sample for that endpoint in PHP unfortunately. Please write the code you need, using the documentation and curl example as a reference, and let us know if something isn't working as expected.
Hi there!
If you need more help you can view your support options (expected response time for a 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!