Fix #3983: Uploads: NoMethodError - undefined method `>=' for nil:NilClass

* Rename Upload#download_for_upload to #get_file_for_upload.

* Fix #get_file_for_upload to raise error if no file or source url was given.

* Fix javascript upload validation to disallow submitting form if file is
  not present and the source is not an url.
This commit is contained in:
evazion
2018-11-11 14:06:35 -06:00
parent e10c6c6a30
commit a20eba9ef7
6 changed files with 36 additions and 22 deletions

View File

@@ -91,12 +91,7 @@ class UploadService
begin
upload.update(status: "preprocessing")
if params[:file].present?
file = params[:file]
elsif upload.source_url.present?
file = Utils.download_for_upload(upload)
end
file = Utils.get_file_for_upload(upload, file: params[:file])
Utils.process_file(upload, file, original_post_id: original_post_id)
upload.rating = params[:rating]