无法将文件上传到Cloudinary [英] Cannot upload files to Cloudinary
问题描述
Cloudinary不允许我上传XLS文件,前提是它支持XLS文件。我正在使用Heroku加载项。
Cloudinary won't let me upload XLS files when it says they support it. I'm using the Heroku add-on.
C:\Users\Chloe\workspace\fortuneempire>rails console
Loading development environment (Rails 5.0.2)
irb(main):001:0> Cloudinary::Uploader.upload('C:\Users\Chloe\Documents\Chocolate_Store1.xls')
CloudinaryException: Invalid image file
from C:/ruby23/lib/ruby/gems/2.3.0/gems/cloudinary-1.8.0/lib/cloudinary/uploader.rb:336:in `block in call_api'
我可以在Cloudinary上托管任何类型的内容吗?
是。 Cloudinary提供了完整的图像管理解决方案,但将管理您丢给它的任何文件类型,包括视频,文本文件等。 Cloudinary将按原样提供此类非映像文件。请注意,您不能使用Cloudinary来管理非法或高度争议的内容。如果不确定文件是否属于此类别,则可能需要阅读我们的服务条款和CDN合作伙伴的可接受使用政策。
Can I host any type of content on Cloudinary? Yes. Cloudinary offers a complete image-management solution, but will manage any file type you throw at it, including videos, textual files and more. Cloudinary will serve such non-image files as-is. Do notice that you can not use Cloudinary to manage illegal or highly controversial content. If you're uncertain whether your files fall into this category, you may want to read our TOS and our CDN partner's Acceptable Use Policy.
https://devcenter.heroku.com/articles/cloudinary
推荐答案
我必须添加:cloudinary_resource_type => :raw
。
if Rails.env == 'production'
has_attached_file :file, :storage => :cloudinary, :path => ':class/:id/:filename',
:cloudinary_resource_type => :raw
http://cloudinary.com/blog/using_cloudinary_to_manage_all_your_website_s_assets_in_the_cloud
https://github.com/GoGoCarl/paperclip-cloudinary#resource-types
这篇关于无法将文件上传到Cloudinary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!