这是我的代码:
return this.http.get(`api/leagues/${id}`).map(res => res.json());
我只是试图进入我已连接的一些相机并将所有图像提取到一个文件中,但它给了我这个错误。弄乱我的一件事是图像存储在DCIM下的子文件夹中。当我只使用.entries时,它会为我提供图像所在的文件夹以及图像。
> !#usr/bin/ruby
require 'fileutils'
Dir.chdir "/home/john/Documents"
if (Dir.exist?("Photoshoot") === false) then
Dir.mkdir "Photoshoot"
puts "Directory: 'Photoshoot' created"
end
Dir.chdir "/run/user/1000/gvfs"
camdirs = Dir.glob('*')
numcams = camdirs.length
camnum = 0
campath = []
while camnum < numcams do
campath.push("/run/user/1000/gvfs/#{camdirs[camnum]}/DCIM")
puts campath[camnum]
camnum += 1
end
campath.each do |path|
Dir.chdir (path)
foldnum = 0
foldir = Dir.glob('*')
puts foldir
Dir.entries("#{path}/#{foldir[foldnum]}").each do |filename|
filetype = File.extname(filename)
if filetype == ".JPG"
FileUtils.mv("#{path}/#{foldir[foldnum]}/#{filename}", "/home/john/Documents/Photoshoot")
end
foldnum += 1
end
end
puts "#{numcams} cameras detected"
有什么建议吗?我无法弄清楚出了什么问题。
答案 0 :(得分:0)
文件路径看起来很奇怪的原因是因为您的相机存储已使用FUSE装入。如果你仔细观察,你会发现它正在寻找:
/run/user/1000/gvfs/gphoto2:host=%5Busb%3A002%2C021%5D/DCIM//IMG_0092.JPG
在最终文件名之前有两个正斜杠。请尝试在应用的第34行进行更正。
如果问题仍然存在,那么在Ruby中运行操作的用户可能没有该文件系统的权限,或者FUSE构造路径的方式与Ruby FileUtils不兼容。
您可以尝试运行:
cat /run/user/1000/gvfs/gphoto2:host=%5Busb%3A002%2C021%5D/DCIM/IMG_0092.JPG
作为运行Ruby进程的同一用户,以确保您具有对文件系统的读取权限。