我正在使用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>这是我的模型。
#talent.rb
attachment :digital_full_length_1, type: :image和我的配置:
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)问题所在。有时,用户放入一些大文件,按下表单上的提交,请求就会中断(超时等)。
有没有办法避免在未使用refile上传文件时发送表单?
谢谢
发布于 2020-05-23 14:23:01
参考他们的documentation https://github.com/refile/refile#5-javascript-library的这一部分。这里有一个如何使用upload:start和upload:success侦听器来实现这一点的示例。
https://stackoverflow.com/questions/59655898
复制相似问题