使用putObject时S3文件已损坏



我正试图使用从Sagemaker端点返回的数据将和对象放入我的s3存储桶中。

<Buffer 50 4b 03 04 14 00 00 00 08 00 6c 83 85 50 2c 2e dd 02 9e 61 93 00 fa 7f a1 00 32 00 00 00 6f 75 74 70 75 74 2f 61 75 64 69 6f 5f 66 69 6c 65 5f 31 35 ... > }

对s3的put请求非常有效。文件大小如预期,为18mb。然而,当我试图在浏览器中播放mp3链接,或下载要播放的文件时,它会显示它给我的文件:

This file isn't playable. That might be because the file type is unsupported, the file extension is incorrect, or the file is corrupt.

这是我的putObject函数:

var params = {
Bucket : 'musicbucket-audio-uploads',
Key : 'test.wav',
Body : data.Body, //This is the Buffer Data
ContentType: 'audio/wav'
};
s3.putObject(params, function(err, data) {
if (err) console.log('PutObject Error: ' + err); 
else     console.log(data);          
});

我想我在putObject的参数中做了一个错误的步骤,但不确定是什么。有人能帮我找出错误吗?

文件的初始字节与WAV fie格式(RIFF(不匹配,看起来也不像MP3。它必须是其他文件格式。我会检查SageMaker模型文档或规范——它对返回缓冲区的格式有什么说明?

更新:似乎是一个ZIP文件。注意,50 4b十六进制字节是PK(对于原始ZIP压缩格式的创建者Phil Katz(。

最新更新