Ruby on Rails: how can I resolve the warning “Digest digest, outdated, using digest” warning when loading into AWS-S3?

I am trying to create an application in which a user can upload, download and transfer music to Amazon Web Services, Simple Storage Services (AWS-S3).

The problem I'm trying to solve is when I try to download an MP3 file, I get a warning in my terminal that repeats exactly four times before I am redirected and warned with my message to the user. "Failed to complete the download." I get a "Digest Digest" warning, I do not recommend using digest when I use the .store method on my AWS object in the upload method.

Has anyone else dealt with this situation and can help me? Thank you very much.

This is my controller:

class SongsController <ApplicationController

  BUCKET = 'batana_application'

  def index
    @songs = AWS::S3::Bucket.find(BUCKET).objects
  end

  def upload
    begin
      AWS::S3::S3Object.store(sanitize_filename(params[:mp3file].original_filename), params[:mp3file].read, BUCKET, :access => :public_read)
      redirect_to root_path
    rescue
      render :text => "Couldn't complete the upload"
    end
  end

  def delete
    if (params[:song])
      AWS::S3::S3Object.find(params[:song], BUCKET).delete
      redirect_to root_path
    else
      render :text => "No song was found to delete!"
    end
  end

  private

  def sanitize_filename(file_name)
    just_filename = File.basename(file_name)
    just_filename.sub(/[^\w\.\-]/,'_')
 end

end

and this is what happens in my terminal when I try to upload a file:

taimurs-mbp:batana taimurknaziri$ rails s
=> Booting WEBrick
=> Rails 4.1.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-08-19 12:19:18] INFO  WEBrick 1.3.1
[2014-08-19 12:19:18] INFO  ruby 2.1.1 (2014-02-24) [x86_64-darwin12.0]
[2014-08-19 12:19:18] INFO  WEBrick::HTTPServer#start: pid=4469 port=3000


Started POST "/songs/upload" for 127.0.0.1 at 2014-08-19 12:19:26 -0400
Processing by SongsController#upload as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"/ZUu7QCsH9D1DYVpXoFkXaOnghbgjm7J/fkJ6zAAmgs=", "mp3file"=>#<ActionDispatch::Http::UploadedFile:0x00000104eaa128 @tempfile=#<Tempfile:/var/folders/l7/f3_r_hhs46lfprth_1pw57vw0000gn/T/RackMultipart20140819-4469-1dw6jsw>, @original_filename="doubletrouble.mp3", @content_type="audio/mp3", @headers="Content-Disposition: form-data; name=\"mp3file\"; filename=\"doubletrouble.mp3\"\r\nContent-Type: audio/mp3\r\n">, "commit"=>"Upload"}
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
  Rendered text template (0.0ms)
Completed 200 OK in 31895ms (Views: 5.8ms | ActiveRecord: 0.0ms)
+4
source share
3 answers

Have you tried to make sure you have the current version of the gem?

Check your gemfile:

gem "aws-sdk", "~> 1.33.0"
+2
source

After reading the documentation that I was able to find provided by AWS, I found out the correct method to call my AWS-S3 object AWS::S3::S3Object. Here , it says that I have to use the .write method on mine AWS::S3::S3Object.

, Digest::Digest is deprecated; use Digest.

+2

I solved this problem by adding to application.rb AWS :: S3 :: DEFAULT_HOST.replace ('s3-us-west-2.amazonaws.com'). In my case, the bucket area is Oregon, and the endpoint is "s3-us-west-2.amazonaws.com" Regions and endpoints

0
source

All Articles