gpt4 book ai didi

ruby-on-rails - Errno::ENOENT:从 S3 中查找视频持续时间时没有此类文件或目录

转载 作者:行者123 更新时间:2023-12-04 23:06:17 24 4
gpt4 key购买 nike

在rails中使用gem paperclip-ffmpeg进行视频。它工作正常,但是当我发现视频的持续时间以秒为单位时,它给了我一个错误

Errno::ENOENT: No such file or directory - the file 'http://getpayad-dev.s3.amazonaws.com/ads/videos/000/000/014/original/Ufone_Tarzan_commercial_%28Ufone_Network_Quality%29_most_Funny_Ad.mp4?1451555000' does not exist
from /home/des0071/.rvm/gems/ruby-2.2.1/gems/streamio-ffmpeg-1.0.0/lib/ffmpeg/movie.rb:11:in `initialize

我的代码是
movie  = FFMPEG::Movie.new("#{self.video.url}")

最佳答案

好吧,这里可以找到 FFMPEG::Movie.new 定义:streamio-ffmpeg/movie.rb

raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)

#ruby 2.2.0p0 (2014-12-25 revision 49005)
File.exists?("http://getpayad-dev.s3.amazonaws.com/ads/videos/000/000/014/original/Ufone_Tarzan_commercial_%28Ufone_Network_Quality%29_most_Funny_Ad.mp4?1451555000")
=> false

问题出在 ruby​​ 的文件类上。所以我尝试了这个:
   File.exists?("http://www.google.com")
=> false

好的,所以要么 google 不在线,要么 File 不能将 URI 作为参数。

A File is an abstraction of any file object accessible by the program and is closely associated with class IO File includes the methods of module FileTest as class methods, allowing you to write (for example) File.exist?("foo"). Class: File Ruby 2.2.0



那么,File Class 真的是 IO 的子类,IO 是怎么说的呢?

Many of the examples in this section use the File class, the only standard subclass of IO. The two classes are closely associated. Like the File class, the Socket library subclasses from IO (such as TCPSocket or UDPSocket). Class:IO Ruby 2.2.0



看起来错误的原因是由于继承,或者因为 gem 不是为了通过 http 流式传输文件而设计的。

关于ruby-on-rails - Errno::ENOENT:从 S3 中查找视频持续时间时没有此类文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34544478/

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