Skip to content
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

upload_file resulting in 'The specified Content-MD5 did not match what we received' error #126

Open
tblais1224 opened this issue Jul 20, 2023 · 4 comments

Comments

@tblais1224
Copy link

tblais1224 commented Jul 20, 2023

Describe the bug
I recently started hitting the error 'The specified Content-MD5 did not match what we received' when using upload_file to send files into box from an AWS file path. The error's began to occur not long after upgrading to ruby 3.2.2, so I'm not sure if that could be related. Box's documentation recommends sending an SHA1 (https://developer.box.com/guides/api-calls/permissions-and-errors/common-errors/#400-bad-request) with the request to resolve this issue but i noticed this only being done in Boxr when using chunk uploads. Any ideas to resolve this one? My next step is going to be setting send_content_md5 to false, but I'm worried this may result in issues down the road with broken file uploads.

To Reproduce
Steps to reproduce the behavior:

  1. call upload_file with a path_to_file and parent

Expected behavior
The file uploads into the box parent folder

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@xhocquet xhocquet added the bug label Jul 20, 2023
@xhocquet
Copy link
Collaborator

Hey @tblais1224 thanks for the report. According to the code, we should be setting it for all file uploads (chunked or not).

Do you happen to have a specific example you could share or is this happening to all of your files? Maybe you could bundle open boxr and throw a debugger in the file I linked above to find out why the MD5 may not be generating as expected.

@tblais1224
Copy link
Author

xhocquet Content-MD5 does appear to be set, is this effectively the same as the sha used here? Perhaps i misunderstood that piece. Either way I'm still hitting these errors for most uploads, previously I had never seen these errors on ruby 2.7.6, only after bumping to 3.2.2 did they begin to occur.

@xhocquet
Copy link
Collaborator

Right, that would be the same thing. One is just passed around more to the lower-level methods whereas the chunked version visibly appends it to the query string params.

Thanks for the report. I don't have bandwidth to investigate this right now, but I encourage you to share your findings if you're able to take a deeper look. I'd be surprised if the SHA1 values changed between Ruby versions, so I wonder what else could be involved.

Maybe you could run a few test requests and compare the SHA values to ones you calculate yourself directly using ruby irb

@tblais1224
Copy link
Author

Following up here, haven't found the cause of the issue but I'm beginning to suspect Box just isn't calculating file sizes correctly. I have been sending files with the arg send_content_md5: false when I hit this error and after downloading the uploaded files from box they seem to be fine. The file I sent to box and downloaded from box appear to have the same file size on my local machine, however I noticed in box its displayed as something different. Usually off by 5 to 25 mb depending on the file size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants