Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 当图片未使用Refile上传时,如何阻止要发送的表单?_Ruby On Rails_Amazon S3_Refile - Fatal编程技术网

Ruby on rails 当图片未使用Refile上传时,如何阻止要发送的表单?

Ruby on rails 当图片未使用Refile上传时,如何阻止要发送的表单?,ruby-on-rails,amazon-s3,refile,Ruby On Rails,Amazon S3,Refile,我使用refile在我的应用程序中上传一些图像 这是我的看法 <span class="file-upload"> <% if current_user.talent.digital_full_length_1.present? %> <figure class="uploaded-img" style="background-image: url( <%= asset_path ix_refile_image_ur

我使用refile在我的应用程序中上传一些图像

这是我的看法

<span class="file-upload">
    <% if current_user.talent.digital_full_length_1.present? %>
        <figure class="uploaded-img" style="background-image: url(  <%= 
        asset_path ix_refile_image_url(current_user.talent, :digital_full_length_1, w: 300, h: 300, fit: 'fill', bg: '0fff') %>);">
            <a href="" title="Remove" class="remove-item">Remove</a>
        </figure>

        <button type="button" class="btn-upload trigger-file-upload hidden"></button>
    <% else %>
        <figure class="uploaded-img hidden" style="background-image: url();">
            <a href="" title="Remove" class="remove-item">Remove</a>
        </figure>

        <button type="button" class="btn-upload trigger-file-upload"></button>
    <% end %>
    <span class="upload-hint">Full Length</span>
    <%= ff.attachment_field :digital_full_length_1, direct: true, presigned: true, class: "user_top_five" %>
</span>
和我的配置:

require "refile/s3"

aws = {
  access_key_id: Rails.application.secrets.S3_ACCESS_KEY_ID,
  secret_access_key: Rails.application.secrets.S3_ACCESS_KEY_SECRET,
  region: Rails.application.secrets.S3_REGION,
  bucket: Rails.application.secrets.S3_BUCKET
}

Refile.cache = Refile::S3.new(prefix: "cache", max_size: 15.megabytes, **aws)
Refile.store = Refile::S3.new(prefix: "store", **aws)
这个问题。有时用户放入一些大文件,按表单上的submit,请求被中断(超时等)

有没有办法避免在文件未使用refile上传时发送表单


感谢您参考他们文档的这一部分。有一个例子说明了如何使用他们的
upload:start
upload:success
监听器实现这一点

require "refile/s3"

aws = {
  access_key_id: Rails.application.secrets.S3_ACCESS_KEY_ID,
  secret_access_key: Rails.application.secrets.S3_ACCESS_KEY_SECRET,
  region: Rails.application.secrets.S3_REGION,
  bucket: Rails.application.secrets.S3_BUCKET
}

Refile.cache = Refile::S3.new(prefix: "cache", max_size: 15.megabytes, **aws)
Refile.store = Refile::S3.new(prefix: "store", **aws)