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
astanley86
9 years agoNew member | Level 2
Get the URL path from a link bookmark .url file
Hello, In my dropbox folder I have a bookmark to a website URL. For example: http://www.google.com - this will be saved as 'Google.url' in my dropbox folder. Which API will return 'http://ww...
- 9 years ago
For .url files, the URL information is saved in the file content. You can use /2/files/download to download the file content, and then parse and use it as desired.
Using your example, if the file is saved as "Google.url" in your Dropbox root folder, you would supply the path "/Google.url" to download the file using the endpoint linked above (or the corresponding method if you're using an SDK or library) and then parse the URL from the returned file content in the response body.
Greg-DB
9 years agoDropbox Staff
For .url files, the URL information is saved in the file content. You can use /2/files/download to download the file content, and then parse and use it as desired.
Using your example, if the file is saved as "Google.url" in your Dropbox root folder, you would supply the path "/Google.url" to download the file using the endpoint linked above (or the corresponding method if you're using an SDK or library) and then parse the URL from the returned file content in the response body.
- astanley869 years agoNew member | Level 2
Thank you, Greg. This gave me what I needed!
I was not familiar with what to with the raw binary data returned from Dropbox. After combining some answers from StackOverflow this is what I came up with which is working for me in my Angular 1 application. I hope this code will help someone else who might be looking for this!
function downloadFile(filePath) { if (!filePath) { console.error('Cannot download file because no file was specified.'); return; } return $q(function(fulfill, reject) { $http({ url: `${dropboxContent}/2/files/download`, method: 'POST', headers: { 'Authorization': 'Bearer {{access-token-goes-here}}', 'Dropbox-API-Arg': `{"path": "${filePath}"}` }, responseType: 'blob' }).then( results => { // data received from dropbox is binary data saved as a blob // The FileReader object lets web applications asynchronously read the contents of files // https://developer.mozilla.org/en-US/docs/Web/API/FileReader var fileReader = new FileReader(); // function will run after successfully reading the file fileReader.onload = function() { var string = this.result; // store the file contents string = encodeURI(string); // get rid of the paragraph return characters var endPosition = string.indexOf('%0D%0A', 32); // find the end of the URL, startPosition is 32 var actualURL = string.substring(32, endPosition); // grab only the characters between start and end positions fulfill(actualURL); }; fileReader.readAsText(results.data); }, error => reject(error)); }); }
The tricky part is that you have to be able to 'read' the blob that is returned, and then extract out just the 'URL'.
- Greg-DB9 years agoDropbox Staff[Cross-linking for reference: https://stackoverflow.com/questions/41273258/read-downloaded-blob-from-dropbox-api-using-http ]
Thanks for sharing your solution!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 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!