-
Notifications
You must be signed in to change notification settings - Fork 0
Enable CHecksum at object finalize #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
fdb34e2
bbcbcec
5475c48
a88e676
9ca62b8
9b3796b
7e09357
23e4ff1
3d35d10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,22 +176,32 @@ def send_upload_command(client) | |
| request_header = header.dup | ||
| request_header[CONTENT_RANGE_HEADER] = get_content_range_header current_chunk_size | ||
| request_header[CONTENT_LENGTH_HEADER] = current_chunk_size.to_s | ||
| last_chunk= remaining_content_size <= current_chunk_size | ||
| hash_data= JSON.parse(body) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Furthermore, if the hash_data = body.to_s.empty? ? {} : JSON.parse(body) |
||
|
|
||
| target_keys = ["crc32c", "md5Hash", "md5"] | ||
| selected_keys = hash_data.slice(*target_keys) | ||
| formatted_string = selected_keys.map do |key, value| | ||
| output_key = (key == "md5Hash") ? "md5" : key | ||
| "#{output_key}=#{value}" | ||
| end.join(',') | ||
| request_header['X-Goog-Hash'] = formatted_string if last_chunk | ||
|
|
||
| chunk_body = | ||
| if @upload_chunk_size == 0 | ||
| upload_io | ||
| else | ||
| StringIO.new(upload_io.read(current_chunk_size)) | ||
| end | ||
|
|
||
| response = client.put(@upload_url, chunk_body, request_header) | ||
|
|
||
| result = process_response(response.status.to_i, response.headers, response.body) | ||
| @upload_incomplete = false if response.status.to_i.eql? OK_STATUS | ||
| @offset += current_chunk_size if @upload_incomplete | ||
| success(result) | ||
|
|
||
| rescue => e | ||
| logger.warn { | ||
| "error occured please use uploadId-#{response.headers['X-GUploader-UploadID']} to resume your upload" | ||
| "error occurred please use uploadId-#{response.headers['X-GUploader-UploadID']} to resume your upload , error==> #{e}" | ||
| } unless response.nil? | ||
| upload_io.pos = @offset | ||
| error(e, rethrow: true) | ||
|
|
@@ -246,7 +256,6 @@ def cancel_resumable_upload(client) | |
|
|
||
| def handle_resumable_upload_http_response_codes(response) | ||
| code = response.status.to_i | ||
|
|
||
| case code | ||
| when 308 | ||
| if response.headers['Range'] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.