gpt4 book ai didi

ruby-on-rails - 获取 Errno::ENOENT: No such file or directory @rb_sysopen 当试图在 Roo gem(Ruby on rails)中打开远程文件 url 时

转载 作者:数据小太阳 更新时间:2023-10-29 08:35:33 27 4
gpt4 key购买 nike

当我尝试使用 roo gem 打开文件导入数据时,我在 AWS s3 存储中存储了一个文件,它引发了以下错误 Errno::ENOENT: No such file or directory @ rb_sysopen

def self.import(file, user_id)
imported_file = ImportedFile.find(file)
spreadsheet = Roo::Spreadsheet.open(open(imported_file.file_url), extension: :csv)
spreadsheet = Roo::Spreadsheet.open(imported_file.file)
header = spreadsheet.row(1)//raising error here
end

这个我也试过

spreadsheet = Roo::Spreadsheet.open(imported_file.file_url)

在日志中获取以下错误

Errno::ENOENT: No such file or directory @ rb_sysopen - /uploads/imported_files/7a6f0463-b3cd-48f8-a579-bc27951242fe/13c96e3e-d3f3-4ed8-8d9a-b9ea03c0cc8c.csv

最佳答案

要打开 URL,您应该首先需要 open-uri 库:

require 'open-uri'

看例子:

open('http://example.com/')
# throws Errno::ENOENT: No such file or directory @ rb_sysopen - http://example.com/

require 'open-uri'
open('http://example.com/')
# opens the website

关于ruby-on-rails - 获取 Errno::ENOENT: No such file or directory @rb_sysopen 当试图在 Roo gem(Ruby on rails)中打开远程文件 url 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46679251/

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