Merge branch 'v1' into es17.01
This commit is contained in:
24
docs/workbook/handling_request/upload_file/application.e
Normal file
24
docs/workbook/handling_request/upload_file/application.e
Normal file
@@ -0,0 +1,24 @@
|
||||
note
|
||||
description: "Basic Service launcher"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_SERVICE [APPLICATION_EXECUTION]
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
-- Initialize current service.
|
||||
do
|
||||
set_service_option ("port", 9090)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,58 @@
|
||||
note
|
||||
description : "Basic Service that show how to Upload a file"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
APPLICATION_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute
|
||||
-- Execute the incomming request
|
||||
local
|
||||
file: WSF_FILE_RESPONSE
|
||||
l_answer: STRING
|
||||
do
|
||||
if request.is_get_request_method then
|
||||
if request.path_info.same_string ("/") then
|
||||
create file.make_html ("upload.html")
|
||||
response.send (file)
|
||||
else
|
||||
-- Here we should handle unexpected errors.
|
||||
end
|
||||
elseif request.is_post_request_method then
|
||||
if request.path_info.same_string ("/upload") then
|
||||
-- Check if we have an uploaded file
|
||||
if request.has_uploaded_file then
|
||||
-- iterate over all the uploaded files
|
||||
create l_answer.make_from_string ("<h1>Uploaded File/s</h1><br>")
|
||||
across request.uploaded_files as ic loop
|
||||
l_answer.append ("<strong>FileName:</strong>")
|
||||
l_answer.append (ic.item.filename)
|
||||
l_answer.append ("<br><strong>Size:</strong>")
|
||||
l_answer.append (ic.item.size.out)
|
||||
l_answer.append ("<br>")
|
||||
end
|
||||
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-type","text/html"],["Content-lenght", l_answer.count.out]>>)
|
||||
response.put_string (l_answer)
|
||||
else
|
||||
-- Here we should handle unexpected errors.
|
||||
create l_answer.make_from_string ("<strong>No uploaded files</strong><br>")
|
||||
l_answer.append ("Back to <a href='/'>Home</a>")
|
||||
response.put_header ({HTTP_STATUS_CODE}.bad_request, <<["Content-type","text/html"],["Content-lenght", l_answer.count.out]>>)
|
||||
response.put_string (l_answer)
|
||||
end
|
||||
else
|
||||
-- Handle error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
51
docs/workbook/handling_request/upload_file/upload.ecf
Normal file
51
docs/workbook/handling_request/upload_file/upload.ecf
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="upload" uuid="274576E6-E7EA-420F-ADED-0CC6955E48DD">
|
||||
<target name="common" abstract="true">
|
||||
<file_rule>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
||||
</target>
|
||||
<target name="upload_standalone" extends="common">
|
||||
<root class="APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<capability>
|
||||
<void_safety support="all"/>
|
||||
</capability>
|
||||
<library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone.ecf"/>
|
||||
<cluster name="upload" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="upload_cgi" extends="common">
|
||||
<root class="APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<capability>
|
||||
<void_safety support="all"/>
|
||||
</capability>
|
||||
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi.ecf"/>
|
||||
<cluster name="upload" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="upload_libfcgi" extends="common">
|
||||
<root class="APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<capability>
|
||||
<void_safety support="all"/>
|
||||
</capability>
|
||||
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi.ecf"/>
|
||||
<cluster name="upload" location=".\" recursive="true"/>
|
||||
</target>
|
||||
<target name="upload" extends="upload_standalone">
|
||||
</target>
|
||||
</system>
|
||||
22
docs/workbook/handling_request/upload_file/upload.html
Normal file
22
docs/workbook/handling_request/upload_file/upload.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EWF Handling Client Request: File Upload Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1> EWF Handling Client Request: File Upload Example</h1>
|
||||
<form action="/upload" enctype="multipart/form-data" method="POST">
|
||||
<fieldset>
|
||||
<legend>Upload file/s</legend>
|
||||
<div>
|
||||
<label>File
|
||||
<input name="file-name[]" type="file" multiple>
|
||||
</label>
|
||||
<fieldset>
|
||||
<div>
|
||||
<button type=submit>Send</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user