无法将文件上传到 Cloudinary

Cannot upload files to Cloudinary

Cloudinary 说支持 XLS 文件,但不让我上传。我正在使用 Heroku 附加组件。

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'

http://cloudinary.com/faq

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

对于 javascript

let headers = new Headers({ name: "X-Requested-With", value: "XMLHttpRequest" });
let url = `https://api.cloudinary.com/v1_1/${cloudinary_config.cloud_name}/image/upload`;
let form: FormData = new FormData();
form.append("upload_preset", cloudinary_config.upload_preset);
form.append("context", `photo=${this.title}`);
form.append("folder", window.location.hostname);
form.append("tags", "myphotoalbum");
form.append("file", file);

this.http.post(url, form).subscribe(
  (data: any) => {
    console.log("sonuc", data);
    this.success(data.toString());
    this.imageUrl.emit(JSON.stringify(data));
  },
  error => {
    this.warn("hata oluştu");
  },
  () => { // "sonuc"
  }

);