我設法弄清楚了,但看起來有點過分。對象層次遍佈整個商店。毫無疑問,我做錯了。
@s3 = Aws::S3::Resource.new()
@bucket = @s3.bucket(bucket_name)
@object = @bucket.object(file_name)
@upload = @s3.client.create_multipart_upload({bucket: bucket_name, key: @object.key})
part1 = {data: "my 1st 5MB chunk", part_number: 1}
part1[:output] = @s3.client.upload_part(body: part1[:data], bucket: bucket_name, key: @object.key, part_number: part1[:part_number], upload_id:@upload.upload_id)
part1[:etag] = part[:output][:etag]
part2 = {data: "my final chunk of any size", part_number: 2}
part2[:output] = @s3.client.upload_part(body: part2[:data], bucket: bucket_name, key: @object.key, part_number: part2[:part_number], upload_id:@upload.upload_id)
part2[:etag] = part[:output][:etag]
@object.multipart_upload(@upload.upload_id).complete(compute_parts: true)
直接與REST API進行通信並不難。如果採取這種方法,您可以以任何對您有意義的方式來管理塊。 –
謝謝,我會看看這些文檔是否更好。但我設法使用Pry和文檔來解決問題。 –