附加下载调整

dev_aliyun
cxt 5 years ago
parent 27d486540a
commit 115a316e80

@ -359,7 +359,7 @@ class AttachmentsController < ApplicationController
saved = @attachment.save
respond_to do |format|
format.js
format.json { render json: { attachment_id: @attachment.id, url: download_attachment_path(@attachment.id) } }
format.json { render json: { attachment_id: @attachment.id, url: "/api/attachments/#{@attachment.id}"} }
format.api {
if saved
render :action => 'upload', :status => :created
@ -380,7 +380,7 @@ class AttachmentsController < ApplicationController
render json: {
success: saved ? 1 : 0, # | 1, // 0 表示上传失败1 表示上传成功
message: "上传信息:#{ @attachment.errors.full_messages.join(',') }",
url: download_attachment_path(@attachment.id), # 上传成功时才返回
url: "/api/attachments/#{@attachment.id}", # 上传成功时才返回
attachment_id: @attachment.id
}
end
@ -413,7 +413,7 @@ class AttachmentsController < ApplicationController
render json: {
success: saved ? 1 : 0, # | 1, // 0 表示上传失败1 表示上传成功
message: "上传失败:#{ @attachment.errors.full_messages.join(',') }",
url: download_attachment_path(@attachment.id) # 上传成功时才返回
url: "/api/attachments/#{@attachment.id}" # 上传成功时才返回
}
end

@ -5691,7 +5691,7 @@ end
def download_named_attachment_url_without_domain(id, filename, option={})
attachment_id = (Attachment === id ? id.id : id)
# Setting.protocol + "://" + Setting.host_name + "/attachments/download/" + attachment_id.to_s + "/" + filename
Setting.protocol + "://" + Setting.host_name + "/attachments/" + attachment_id.to_s
"/api/attachments/" + attachment_id.to_s
end
def named_attachment_url_without_domain(id, filename, option={})

@ -73,7 +73,7 @@
<div class="surfacePlot ml60 library-cover-select" data-tip-down="上传图片" onclick="$('#library-cover-file').click();">
<img src="/images/educoder/unite.png" class="marginuploading <%= cover_exists ? 'hidden' : '' %>" style="<%= cover_exists ? 'display:none' : '' %>"/>
<div class="library-cover-perview" style="<%= cover_exists ? '' : 'display:none' %>">
<% cover_url = cover_exists ? download_attachment_path(@library.cover_id) : '' %>
<% cover_url = cover_exists ? "/api/attachments/#{@library.cover.id}" : '' %>
<img src="<%= cover_url %>" width="122px" height="93px"/>
</div>
</div>

@ -2,7 +2,7 @@
<% if @libraries.present? %>
<% @libraries.each do |library| %>
<li class="library_list_item">
<% image_url = library.cover.present? ? download_attachment_path(library.cover.id) : 'educoder/library-default-cover.png' %>
<% image_url = library.cover.present? ? "/api/attachments/#{library.cover.id}" : 'educoder/library-default-cover.png' %>
<%= image_tag(image_url, width: 120, height: 90, class: 'mr15 mt3 radius4') %>
<div class="flex1">
<p class="clearfix mb15 lineh-40 mt10">

@ -8,7 +8,7 @@
<td><%= training.training_payinfo.try(:info) %></td>
<td>
<% if training.training_payinfo.try(:attachment_id).present? %>
<img src="<%= download_attachment_path(training.training_payinfo.try(:attachment_id)) %>" width="50px" class="training_image"/>
<img src="/api/attachments/<%= training.training_payinfo.try(:attachment_id) %>" width="50px" class="training_image"/>
<% end %>
</td>
<td><%= format_time training.created_at %></td>

Loading…
Cancel
Save