We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
jdwileymon
7 years agoExplorer | Level 3
Audio files uploaded give "audio error has occurred" and the files are corrupted
As in the title, more details here: https://stackoverflow.com/questions/50223863/uploaded-wav-audio-file-is-unreadable-corrupted?noredirect=1#comment87465268_50223863
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.
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
7 years agoExplorer | 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.
- jdwileymon7 years agoExplorer | Level 3To your question of "req.body.file" - that's the data I'm passing, either File object, blob, etc.
- Greg-DB7 years agoDropbox StaffWhat 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
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 2 hours 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!