简体   繁体   中英

how to download a zip file from s3 bucket using ruby

i am able to zip all required files(using ruby gems of AWS SDK) & upload them to the S3 bucket. when i tried to download the zip files from S3 to local server & unzip them , i am geeting following error...

[2013-05-06T07:19:37+00:00] FATAL: TypeError: aws_unzip[db_unzip] (aws::unzip line 14) had an error: TypeError: can't dup NilClass

Even when i try to unzip manually, i can see "zip files is corrupted"...But the zip file which is present in S3 location is not corrupted(i tested to extract them manually by downloading them, it extracted well).... Can any one help where i am doing mistake in reading zip files from bucket to local server????? When downloading it is getting corrupted...

My code is

File.open(dd, 'w') {|f| f.write(obj.read.force_encoding('utf-8'))}

Try 'wb' mode - zip is a binary file. Also that force_encoding is very suspicious.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM