One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
Mert
6 years agoNew member | Level 2
axios downloaded an mp3 file from dropbox api is empty, 0 bytes in react native
getmedia(medianame) {
console.log(medianame);
path1 = RNFS.DocumentDirectoryPath + '/' + medianame;
console.log(path1);
axios({
method: 'POST',
url: 'https://content.dropboxapi.com/2/files/download',
headers: {
Authorization: 'Bearer JxxxxxxxxxxC7JnnYdLgKrxxyxyxyxyxyyxyxyxeeee',
'Dropbox-API-Arg': '{ "path": "/Apps/Myapp/+ medianame" }',
'Content-Type': 'text/plain',
Host: 'content.dropboxapi.com'
}
})
.then((response) => {
console.log(response);
RNFS.writeFile(path1, response, 'utf8')
.then((success) => {
console.log('FILE WRITTEN!');
})
.catch((err) => {
console.log(err.message);
});
});
}
I am using axios with post method to download an mp3 file from dropbox and ı write the response to the app folder but in app folder file seems to have 0 bytes, empty. What might be the problem?
- Greg-DB
Dropbox Staff
The /2/files/download endpoint is the right endpoint for downloading file data. If the call is successful, the response body will be the file data. There are a number of ways for the call to fail though, e.g., if the path you provide is incorrect.
It looks like you're not catching any potential errors on the /2/files/download call. You should add a catch to Dropbox API call itself (similar to the one you have for the local file writing operation). That way, you can detect when the call fails.
For instance, looking at your code, it looks like you may be supplying the wrong path value. When using an app with the "app folder" permission, you shouldn't explicitly include the "/Apps/Myapp" portion in your file paths. That part is automatically assumed for you. So, if you're trying to access a file at "/Apps/Myapp/file.ext" with the app for that app folder, you should just supply "/file.ext".
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 6 hours ago
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 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!