Google Cloud Storage .flacaudiofile upload失败(Nodejs)

我正在使用Google Cloud Storage和Speech API从我的node.js实现中转换文件audio,并且在将FLAC编码的audiofile upload到Google Cloud Storage中时遇到问题。 它似乎只能正确地上传短于大约15-20秒的文件,对于其他人来说,API不会抛出错误并保存一个空文件(8.16KB)。

涉及的代码部分如下:

... var binary = new Buffer(audio, 'base64'); // write buffer to file var Readable = require('stream').Readable var s = new Readable s.push(binary) // the string you want s.push(null) // indicates end-of-file basically - the end of the stream var convertedFLACfilePath = "" + crypto.randomBytes(32).toString('hex')+".flac"; var FfmpegCommand = require('fluent-ffmpeg'); var command = new FfmpegCommand().input(s) .audioCodec('flac').save(convertedFLACfilePath) .on('error', function(err) { console.log('An error occurred: ' + err.message); }) .on('end', function() { console.log('Processing finished !'); const gcloudAuth = { projectId: '-------', keyFilename: '--------' }; const bucketName = '--------'; const filename = convertedFLACfilePath; const gcsUri = 'gs://' + bucketName + '/' + filename; const encoding = 'FLAC'; const sampleRateHertz = 16000; const languageCode = '----'; var gcloud = require('google-cloud')(); var storageClient = gcloud.storage(gcloudAuth); var bucket = storageClient.bucket(bucketName); bucket.upload(filename) .then(() => { console.log(filename + ' uploaded to ' + bucketName); var speechClient = gcloud.speech(gcloudAuth); const config = { encoding: encoding, sampleRateHertz: sampleRateHertz, languageCode: languageCode }; const audio = { uri: gcsUri //content: fs.readFileSync(filename).toString('base64'), }; ... 

这种types的操作有一些限制吗? 谢谢Alex。