Migrated most of the example and library to new design.
This commit is contained in:
@@ -8,20 +8,19 @@ class
|
||||
IMAGE_UPLOADER_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_EXECUTION
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_ROUTED_SKELETON_EXECUTION
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -41,7 +40,7 @@ feature {NONE} -- Initialization
|
||||
map_uri_template_agent_with_request_methods ("/upload/{name}{?nb}", agent execute_upload_put, router.methods_put)
|
||||
map_uri_template_agent ("/upload{?nb}", agent execute_upload)
|
||||
|
||||
create www.make (document_root)
|
||||
create www.make_with_path (document_root)
|
||||
www.set_directory_index (<<"index.html">>)
|
||||
www.set_not_found_handler (agent execute_not_found)
|
||||
router.handle_with_request_methods ("", www, router.methods_GET)
|
||||
@@ -49,31 +48,16 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Configuration
|
||||
|
||||
document_root: READABLE_STRING_8
|
||||
document_root: PATH
|
||||
-- Document root to look for files or directories
|
||||
local
|
||||
e: EXECUTION_ENVIRONMENT
|
||||
dn: DIRECTORY_NAME
|
||||
once
|
||||
create e
|
||||
create dn.make_from_string (e.current_working_directory)
|
||||
dn.extend ("htdocs")
|
||||
Result := dn.string
|
||||
if Result [Result.count] = Operating_environment.directory_separator then
|
||||
Result := Result.substring (1, Result.count - 1)
|
||||
end
|
||||
ensure
|
||||
not Result.ends_with (Operating_environment.directory_separator.out)
|
||||
Result := execution_environment.current_working_path.extended ("htdocs")
|
||||
end
|
||||
|
||||
files_root: READABLE_STRING_8
|
||||
files_root: PATH
|
||||
-- Uploaded files will be stored in `files_root' folder
|
||||
local
|
||||
dn: DIRECTORY_NAME
|
||||
once
|
||||
create dn.make_from_string (document_root)
|
||||
dn.extend ("files")
|
||||
Result := dn.string
|
||||
Result := document_root.extended ("files")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
@@ -109,8 +93,7 @@ feature -- Execution
|
||||
n := 1
|
||||
end
|
||||
if attached {WSF_STRING} req.query_parameter ("demo") as p_demo then
|
||||
create fn.make_from_string (document_root)
|
||||
fn := fn.extended (p_demo.value)
|
||||
fn := document_root.extended (p_demo.value)
|
||||
l_body.append ("File: <input type=%"file%" name=%"uploaded_file[]%" size=%"60%" value=%""+ html_encode (fn.name) +"%"></br>%N")
|
||||
end
|
||||
|
||||
@@ -134,9 +117,8 @@ feature -- Execution
|
||||
n := n + 1
|
||||
l_body.append ("<li>")
|
||||
l_body.append ("<div>" + c.item.name + "=" + html_encode (c.item.filename) + " size=" + c.item.size.out + " type=" + c.item.content_type + "</div>")
|
||||
create fn.make_from_string (files_root)
|
||||
l_safe_filename := c.item.safe_filename
|
||||
fn := fn.extended (l_safe_filename)
|
||||
fn := files_root.extended (l_safe_filename)
|
||||
if c.item.move_to (fn.name) then
|
||||
if c.item.content_type.starts_with ("image") then
|
||||
l_body.append ("%N<a href=%"../files/" + url_encode (l_safe_filename) + "%"><img src=%"../files/"+ l_safe_filename +"%" /></a>")
|
||||
@@ -182,8 +164,7 @@ feature -- Execution
|
||||
if attached new_temporary_output_file ("tmp-uploaded-file_" + n.out) as f then
|
||||
req.read_input_data_into_file (f)
|
||||
f.close
|
||||
create fn.make_from_string (files_root)
|
||||
fn := fn.extended (l_safe_filename)
|
||||
fn := files_root.extended (l_safe_filename)
|
||||
f.rename_file (fn.name)
|
||||
l_body.append ("<li>")
|
||||
l_body.append ("<div>Input data : size=" + f.count.out + " (" + req.content_length_value.out + ")</div>")
|
||||
|
||||
Reference in New Issue
Block a user