mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Allow api to send uploads with :url
This commit is contained in:
parent
ca42d00883
commit
131cf643ce
2 changed files with 18 additions and 2 deletions
|
@ -4,7 +4,7 @@ class UploadsController < ApplicationController
|
|||
|
||||
def create
|
||||
type = params.require(:type)
|
||||
file = params[:file] || params[:files].first
|
||||
file = params[:file] || params[:files].try(:first)
|
||||
url = params[:url]
|
||||
client_id = params[:client_id]
|
||||
synchronous = is_api? && params[:synchronous]
|
||||
|
@ -52,7 +52,7 @@ class UploadsController < ApplicationController
|
|||
# API can provide a URL
|
||||
if file.nil? && url.present? && is_api?
|
||||
tempfile = FileHelper.download(url, SiteSetting.max_image_size_kb.kilobytes, "discourse-upload-#{type}") rescue nil
|
||||
filename = File.basename(URI.parse(file).path)
|
||||
filename = File.basename(URI.parse(url).path)
|
||||
else
|
||||
tempfile = file.tempfile
|
||||
filename = file.original_filename
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue