Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:03:11+00:00 2026-06-15T07:03:11+00:00

as stated, i am trying to upload a file to s3 require ‘digest/md5’ require

  • 0

as stated, i am trying to upload a file to s3

require 'digest/md5' 
require 'base64' 
require 'aws-sdk'

def digest f

 f.rewind

 Digest::MD5.new.tab do |dig|

  f.each_chunk{|ch| dig << ch}

 end.base64digest

ensure

 f.rewind

end 

file = File.new(compress file) #file zipped with zip/zip

total = file.size

digest = digest(file)

s3 = AWS::S3::new(:access_key_id => @access_key_id, :secret_access_key
=> @secret_access_key)

bucket = s3.buckets['mybucket']

bucket.objects["myfile"].write :content_md5 => digest, :content_length
=> total do |buf,len|

 buf.write(file.read len)

end

but i constantly get AWS::S3::Errors::BadDigest exception

if i try to upload the file without passing :content_md5, everything goes well, archive downloads and opens correctly.

also as i just found out this fails on ruby 1.9.3 but works well on 1.9.2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:03:12+00:00Added an answer on June 15, 2026 at 7:03 am

    fixed by changing digest func to

    def digest f

    Digest::MD5.file(f.path).base64digest
    

    end

    i think the issue was in the fact that the file passed to it was open

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload a file to my server using the CakePHP file upload
I'm trying to upload a file onto my personal server. I've written a small
I'm trying to get a file upload progress bar working in a rails 3
I'm trying to provide live parsing of a file upload in CGI and show
Got a little situation here where I am trying to cancel a file's upload.
im trying to use a file upload control from the obout control library, i
I am trying to upload a file using rich:fileUploader and its not triggering the
I'm trying to have a simple form with a file upload, but it isn;t
For some reason when trying to upload a zip file this function always returns
I'm trying to get a simple file upload working using jquery-fileupload-rails carrierwave fog I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.