1
sftpサーバーからzipファイルを読み込んでS3にポストすると、ファイルをダウンロードして読み取ることができません。以下のようにファイルを解凍しようとしてコンソールからエラーが読み:SFTPからファイルを読み込むためのノードとAWSを使用してSFTPサーバーからS3にポストされた後、Zipファイルを展開できないラムダ
unzip -l 7375_FAIL_test_20160626_185904.txt.zip
Archive: 7375_FAIL_test_20160626_185904.txt.zip
warning [7375_FAIL_test_20160626_185904.txt.zip]: 4 extra bytes at beginning or within zipfile
(attempting to process anyway)
error [7375_FAIL_test_20160626_185904.txt.zip]: start of central directory not found;
zipfile corrupt.
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
ザ・jsのコードはここにある:
.then(function(fileInfo) {
return sftp.openAsync(dir + '/' + fileInfo.filename, 'r')
.then(function(handle) {
console.log(fileInfo.attrs.size)
var result = new Buffer(fileInfo.attrs.size);
return sftp.readAsync(handle, result, 0, fileInfo.attrs.size, 0)
.then(function(data) {
return process(result.toString());
})
.then(function(data) {
return sftp.closeAsync(handle)
.then(function() {
return data;
});
})
4 extra bytes at beginning or within zipfile
が起こっかもしれない理由上の任意の考えまたはこの問題を解決する方法は?
ありがとうございます!
私はほとんど同じことをやりたいです。ラムダコードを私と共有していただけますか?私はそれをデバッグし、あなたを助けるかもしれません。 –
S3にコードをアップロードする 'process()'はありますか?もしそうなら、 'result'に対して' .toString() 'を呼び出すべきではないでしょう。 – robertklep
@AkarshSatija残念ながら、このレポはプライベートですが、実際にはhttps://github.com/gilt/s3-sftp-bridgeのカスタマイズ版です。 – weilandia