gpt4 book ai didi

ruby-on-rails - ruby rails : How can I resolve the "Digest::Digest is deprecated; use Digest" warning when uploading to AWS-S3?

转载 作者:数据小太阳 更新时间:2023-10-29 07:32:02 25 4
gpt4 key购买 nike

我正在尝试制作一个应用程序,用户可以在其中将音乐上传、下载和流式传输到 Amazon Web Services、Simple Storage Services (AWS-S3)。

我试图解决的一个问题是,当我尝试上传 MP3 文件时,我在终端中收到一条警告,该警告在我被重定向并向用户发出消息“无法完成上传”。当我在上传方法中对我的 AWS 对象使用 .store 方法时,我收到“Digest::Digest is deprecated; use Digest”警告。

有没有其他人处理过这种情况并且可以帮助我?非常感谢,非常感谢。

这是我的 Controller :

类 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

这是我尝试上传文件时终端中发生的情况:

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)

最佳答案

您是否尝试过确保您拥有当前版本的 gem?

检查你的 gemfile:

gem "aws-sdk", "~> 1.33.0"

关于ruby-on-rails - ruby rails : How can I resolve the "Digest::Digest is deprecated; use Digest" warning when uploading to AWS-S3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25389624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com