0

Using the dropbox javascript SDK, i'm attempting to upload some .wav audio files to a dropbox folder.

However, the files uploaded are unreadable and give a "audio error" when opened or previewed. The code I'm using is:

var Dropbox = require('dropbox').Dropbox;
var dbx = new Dropbox({ accessToken: 'accesstoken' });
    dbx.filesUpload({path: filePath, contents: req.body.file, mode: 'overwrite'})
              .then(function(response) {
                console.log("audio saved!");
                res.sendStatus(200);            
              })
              .catch(function(error) {
                console.error(error);
                response.sendStatus(400);
              });

filePath is the folder structure + name of the file, ex: /DropboxRoot/Audio/sounds.wav

For the contents, I have tried many things in the attempt that the data is being uploaded in the wrong format. So far I've tried:

  1. Blob - Blob(123456){size:123456, type:"audio/wav"}
  2. ArrayBuffer

Am I uploading the data incorrectly? The audio blob can be used successfully as audio before being sent to the server.

I record the audio using this free code and play it back by loading it to the source of an Audio element like so:

<audio controls>
              <source src="" type="audio/wav" />
            </audio>

The "source" is set to var url = (window.URL || window.webkitURL).createObjectURL(blob)

3
  • The audio blob can be used successfully as audio before being sent to the server. how are you both recording / generating this audio blob, then how are you playing it back? Maybe DropBox thinks it's a WAV, but its actually an MP3? Maybe it doesnt even have the proper file headers for a WAV, but is just the raw binary data?
    – Matt Clark
    Commented May 7, 2018 at 23:44
  • @MattClark See updated question
    – JWiley
    Commented May 7, 2018 at 23:53
  • [Cross-linking for reference: dropboxforum.com/t5/API-Support-Feedback/… ]
    – Greg
    Commented May 8, 2018 at 19:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.