下载文件链接encode

This commit is contained in:
xxq250 2023-06-28 11:14:58 +08:00
parent ff53e15b31
commit 64e85397f3
1 changed files with 2 additions and 2 deletions

View File

@ -40,10 +40,10 @@ class AttachmentsController < ApplicationController
url.gsub!(url.split("/")[-1], '')
puts filepath
request_url = [domain, api_url, url, CGI.escape(filepath), "?ref=#{CGI.escape(ref.split('ref=')[1])}&access_token=#{User.where(admin: true).take&.gitea_token}"].join
response = Faraday.get(request_url)
response = Faraday.get(URI.encode(request_url))
filename = filepath
else
response = Faraday.get(url)
response = Faraday.get(URI.encode(url))
filename = params[:download_url].to_s.split("/").pop()
end
send_data(response.body.force_encoding("UTF-8"), filename: filename, type: "application/octet-stream", disposition: 'attachment')