在上传到S3的过程中,ZIP文件被破坏

我使用node.js和knox的putFile将一个zipfile upload到S3。 原来的压缩文件打开,从S3的压缩下载是腐败的。

以下是我正在使用的相关代码:

var client = knox.createClient({ key: 'MY KEY HERE', secret: 'MY SECRET HERE', bucket: 'MY BUCKET HERE' }); var filename = 'example.zip'; var req = client.putFile(filename, filename, { 'x-amz-acl': 'public-read' }, function(err, res){ if (res.statusCode == 200) { console.log('moved '+filename+' to s3'); } else { console.log('failed to move to s3'); } }); 

这是我在使用OSX上的zip文件修复zip文件时得到的输出结果

 > zip -F remote.zip --out fixed-remote.zip Fix archive (-F) - assume mostly intact archive zip warning: bad archive - missing end signature zip warning: (If downloaded, was binary mode used? If not, the zip warning: archive may be scrambled and not recoverable) zip warning: Can't use -F to fix (try -FF) zip error: Zip file structure invalid (remote.zip) > zip -FF remote.zip --out fixed-remote.zip zip warning: Missing end (EOCDR) signature - either this archive is not readable or the end is damaged > Is this a single-disk archive? (y/n): y Assuming single-disk archive [LISTS ALL FILES COPIED HERE] zip warning: no end of stream entry found: awesome-file.jpg zip warning: rewinding and scanning for later entries 

我完全失去了为什么这会发生。 几乎看起来,最后几个字节不是由诺克斯发送,但这是一个新的猜测。

有人有主意吗?

更新:

我认为这可能是生成ZIP文件的问题,而不是上传。 我尝试上传由OSX Zip实用程序生成的zip文件,并且每次都正常工作。 我会深入一点。 谢谢您的帮助。

便捷API(如putFile和putStream)目前无法像美国标准以外的区域中的桶一样使用,也没有明确指定区域选项。

确保添加您的区域: https : //github.com/LearnBoost/knox#region

 var client = knox.createClient({ key: 'MY KEY HERE', secret: 'MY SECRET HERE', bucket: 'MY BUCKET HERE', region: 'us-standard' }); 

似乎工作? 文件大小对我来说是一样的: 输出:

 node aws.js { Name: 'MYBUCKET', Prefix: '', Marker: '', MaxKeys: 1000, IsTruncated: false, Contents: [ { Key: 'hudson_out.jpg', LastModified: Wed May 29 2013 12:38:50 GMT-0400 (EDT), ETag: '"996f46db285c900f3e1596d484a72fb4"', Size: 1690706, Owner: [Object], StorageClass: 'STANDARD' } ] } moved hudson_out.jpg to s3 

ls -la hudson_out.jpg -rw-r – r – @ 1(stuff)1690706 2012年8月31日hudson_out.jpg