Display the full url for uploaded files via the CMS_FILES_MODULE.

Keep db/mails in checkout.
This commit is contained in:
Jocelyn Fiat
2017-03-28 22:26:21 +02:00
parent 307a87eaf4
commit 134f876e62
2 changed files with 13 additions and 5 deletions

View File

@@ -97,7 +97,7 @@ feature -- Access: router
do
map_uri_template_agent (a_router, "/" + uploads_location, agent execute_upload (?, ?, a_api), Void) -- Accepts any method GET, HEAD, POST, PUT, DELETE, ...
map_uri_template_agent (a_router, "/" + uploads_location + "{filename}", agent display_uploaded_file_info (?, ?, a_api), a_router.methods_get)
map_uri_template_agent (a_router, "/" + uploads_location + "remove/{filename}", agent remove_file (?, ?, a_api), a_router.methods_get)
map_uri_template_agent (a_router, "/" + uploads_location + "{filename}/remove", agent remove_file (?, ?, a_api), a_router.methods_get)
end
uploads_location: STRING = "upload/"
@@ -133,6 +133,7 @@ feature -- Handler
local
body: STRING_8
r: CMS_RESPONSE
l_file_url: STRING_8
f: CMS_FILE
md: detachable CMS_FILE_METADATA
fn: READABLE_STRING_32
@@ -193,12 +194,18 @@ feature -- Handler
else
body.append ("NA")
end
body.append ("<br/>%N")
--| File Url
l_file_url := req.script_url ("/" + l_files_api.file_link (f).location)
body.append ("<strong>File URL: </strong>")
body.append (l_file_url)
body.append ("<br/><br/>%N")
body.append ("<a class=%"button%" href=%"" + req.script_url ("/" + l_files_api.file_link (f).location) + "%">Download</a>%N")
body.append ("<a class=%"button%" href=%"" + req.script_url ("/" + uploads_location + "remove/" + f.filename) + "%">Remove</a>%N")
body.append ("<a class=%"button%" href=%"" + l_file_url + "%">Download</a>%N")
body.append ("<a class=%"button%" href=%"" + req.script_url ("/" + uploads_location + f.filename + "/remove") + "%">Remove</a>%N")
body.append ("</div>%N") -- metadata
body.append ("<br/>%N")
body.append ("<div class=%"overview%">")
if
attached f.relative_path.extension as ext and then
@@ -425,7 +432,7 @@ feature -- Handler
-- add remove button
a_output.append ("<td>")
a_output.append ("<a class=%"button%" href=%"" + req.script_url ("/" + uploads_location + "remove/" + f.filename) + "%">Remove</a>%N")
a_output.append ("<a class=%"button%" href=%"" + req.script_url ("/" + uploads_location + f.filename + "/remove") + "%">Remove</a>%N")
a_output.append ("</td>%N")
a_output.append ("</tr>%N")