Browse Source

下载文件链接encode

pull/338/head
xxq250 3 years ago
parent
commit
64e85397f3
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      app/controllers/attachments_controller.rb

+ 2
- 2
app/controllers/attachments_controller.rb 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')


Loading…
Cancel
Save