我使用 carrierwave_direct 上传文件,但是当上传的文件为空时,我收到了这样的错误:
<Error><Code>EntityTooSmall</Code><Message>Your proposed upload is smaller than the minimum allowed size</Message><MinSizeAllowed>1</MinSizeAllowed><ProposedSize>0</ProposedSize><RequestId>FE2FE66371A06E29</RequestId><HostId>k3aJ8EtnmPvVxJszZukKYbtEO5Ddrjq/a+FdhqTyL1nZ7afy+msTAA1MiwX8lXvH</HostId></Error>
如何捕捉这个异常?我的代码:
collection_action :new_import do
@uploader = @organization.import_file
@organization.save
@uploader.success_action_redirect = import_admin_organization_rooms_url(@organization)
end
collection_action :import do
RoomImportWorker.perform_async(params[:bucket],params[:key],@organization.id,current_user.id)
redirect_to admin_organization_rooms_path(@organization), :notice => "Your request has been accepted! We will inform you via email about the results!"
end