简体   繁体   English

在 Rails 上使用 Ruby 将.zip 文件上传到 Cloudinary

[英]Uploading .zip file to Cloudinary using Ruby on Rails

I have Cloudinary API added to my Rails 6 application.我已将 Cloudinary API 添加到我的 Rails 6 应用程序中。 Photo extensions and video extension uploads work great.照片扩展和视频扩展上传效果很好。 .zip extensions do not. .zip 扩展没有。 I've run into two errors while trying to upload a zip file.我在尝试上传 zip 文件时遇到了两个错误。

  • CloudinaryException (Unsupported ZIP file): CloudinaryException(不支持的 ZIP 文件):
  • ActiveModel::UnknownAttributeError (unknown attribute 'type' for Photo.) ActiveModel::UnknownAttributeError(照片的未知属性“类型”。)

In my controller for uploading the zip file, I tried to upload a zip file in different ways.在用于上传 zip 文件的 controller 文件中,我尝试以不同方式上传 zip 文件。

First I tried首先我试过

  @value = Cloudinary::Uploader.upload(params[:downloadable],
  folder: "game_zip", resource_type: :raw)

Second I tried第二个我试过

  @value = Cloudinary::Uploader.upload(params[:downloadable])

Third I tried第三个我试过

@value = Cloudinary::Uploader.upload(params[:downloadable],
:resource_type => :auto)

I read in Cloudinary documents that using raw file types is how you can upload zip files, I tried what they recommended, but it's not working.我在 Cloudinary 文档中读到,使用原始文件类型是上传 zip 文件的方法,我尝试了他们推荐的方法,但它不起作用。 Is there a solution or option that I need to add?是否有我需要添加的解决方案或选项?

Cloudinary recently updated its security policies, and now restricts both pdf and archive file types on new Free accounts. Cloudinary 最近更新了其安全策略,现在限制了pdf和新免费帐户上的存档文件类型。

This can be bypassed by contacting Cloudinary's support , or by upgrading your account.这可以通过联系 Cloudinary 的支持或升级您的帐户来绕过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM