fix: write image filepath error
This commit is contained in:
parent
998381585a
commit
a543c3e08f
|
@ -74,6 +74,7 @@ vendor/bundle/
|
|||
/log
|
||||
/public/admin
|
||||
/mysql_data
|
||||
/public/repo/
|
||||
|
||||
|
||||
.generators
|
||||
|
|
|
@ -10,7 +10,7 @@ module RepositoriesHelper
|
|||
end
|
||||
|
||||
def download_type(str)
|
||||
default_type = %w(xlsx xls ppt pptx pdf zip 7z rar exe pdb obj idb png jpg gif tif psd svg RData rdata doc docx mpp vsdx dot)
|
||||
default_type = %w(xlsx xls ppt pptx pdf zip 7z rar exe pdb obj idb png jpg gif tif psd svg RData rdata doc docx mpp vsdx dot otf eot ttf woff woff2)
|
||||
default_type.include?(str&.downcase)
|
||||
end
|
||||
|
||||
|
@ -82,7 +82,9 @@ module RepositoriesHelper
|
|||
readme_render_decode64_content(content, path)
|
||||
else
|
||||
file_type = entry['name'].to_s.split(".").last
|
||||
return entry['content'] if download_type(file_type)
|
||||
if download_type(file_type)
|
||||
return entry['content'].nil? ? Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content'] : entry['content']
|
||||
end
|
||||
render_decode64_content(entry['content'])
|
||||
end
|
||||
end
|
||||
|
@ -94,14 +96,15 @@ module RepositoriesHelper
|
|||
end
|
||||
|
||||
def render_download_image_url(dir_path, file_path, content)
|
||||
full_path = file_path.starts_with?("/") ? [dir_path, file_path].join("") : [dir_path, file_path].join("/")
|
||||
file_name = full_path.split("/")[-1]
|
||||
# 用户名/项目标识/文件路径
|
||||
dir_path = generate_dir_path(dir_path)
|
||||
dir_path = generate_dir_path(full_path.split("/"+file_name)[0])
|
||||
|
||||
file_path = [dir_path, file_path].join('/')
|
||||
file_path = [dir_path, file_name].join('/')
|
||||
|
||||
puts "##### render_download_image_url file_path: #{file_path}"
|
||||
base64_to_image(file_path, content)
|
||||
|
||||
file_path = file_path.split('public')[1]
|
||||
File.join(base_url, file_path)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue