Created
December 17, 2012 12:34
-
-
Save yosukehara/4317971 to your computer and use it in GitHub Desktop.
I tried multipart-upload-api with Ruby. Sample code is as the follows:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
Endpoint = "localhost" | |
Port = 8080 | |
class LeoFSHandler < AWS::Core::Http::NetHttpHandler | |
def handle(request, response) | |
request.port = ::Port | |
super | |
end | |
end | |
AWS.config( | |
:access_key_id => '05236', | |
:secret_access_key => '802562235', | |
s3_endpoint: Endpoint, | |
http_handler: LeoFSHandler.new, | |
s3_force_path_style: true, | |
use_ssl: false | |
) | |
file_path_for_multipart_upload = 'test-large-file.tar.gz' | |
bucket = AWS::S3.new.buckets['photo'] | |
open(file_path_for_multipart_upload) do |file| | |
uploading_object = bucket.objects[File.basename(file.path)] | |
uploading_object.multipart_upload do |upload| | |
while !file.eof? | |
# upload.add_part(file.read 5242880) ## 5242880 : 5MB | |
upload.add_part(file.read 15728640) ## 15728640 : 15MB | |
p('Aborted') if upload.aborted? | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gateway/etc/app.config
s3cmd
Curl command's result: