cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Audio files uploaded give "audio error has occurred" and the files are corrupted

Audio files uploaded give "audio error has occurred" and the files are corrupted

jdwileymon
Explorer | Level 3
4 Replies 4

Greg-DB
Dropbox Staff
It looks like there are a few parts to your code on StackOverflow, so it would be good to isolate where the issue is exactly. I.e., where does the data go from being the expected value to something else?

There's an example of uploading using the JavaScript SDK here, where the file object is passed in directly to the 'contents' parameter of the filesUpload method:

https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/javascript/upload/index.html#L54

That example works fine for me. Are you able to run it successfully?

For your code, what environment are you using, and what is `req.body.file` exactly? Where is the data that you want to upload coming from originally?

In order to validate the uploaded file, you can `console.log(response)` to see the metadata for the uploaded file, e.g., to see the file size. I also recommend checking the uploaded file on the Dropbox web site, in order to see if it worked as expected before adding other potential points of failure.

jdwileymon
Explorer | Level 3

I took the example code from that and plugged it in to my use case. Meaning, instead of recording audio to send as the file I uploaded from the file input, but it gave me the same error. 

 

To your point of the data expected vs something else, I'm confused as to what that data should be. To the examples, I assumed I could take the data (i.e. the recorded audio in Blob form) and pass it as a file. I've also tried converting the Blob to File: var fileBlob = new File([myblob], "filename"); as I saw this example passing the file object directly, but it's still not openable or useable after upload.

 

The environment is node.js server and everything else (audio recording) in browser. `console.log(response)` shows [Object] for when I send the data converted to File, or as the other types I specified in my attempts (string, encoded string, etc).

 

Checking the file in Dropbox via the site is the problem I'm referring to, it gives an "an audio error occurred" there, and when synced loads as "corrupted". Let me know if I can provide more info.

jdwileymon
Explorer | Level 3
To your question of "req.body.file" - that's the data I'm passing, either File object, blob, etc.

Greg-DB
Dropbox Staff
What is the type and size of "req.body.file" before you modify it though, and what does it contain?

It's hard to offer insight as I don't know exactly what you're working with. Are you using Express or something? Is `req.body.file` getting set by some middleware? What, if so? It might be more helpful if you can provide a full sample.

Also, in Node, `console.log(response)` will just show you the type in this case, but you can access the different properties, e.g., `response.size`.

By the way, I linked to the browser JavaScript upload example, but here's the Node JavaScript upload example:

https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/javascript/node/upload.js#L17
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    jdwileymon Explorer | Level 3
What do Dropbox user levels mean?