Merged V2.1 to HEAD

6374: AR-1639 Web Script Content Upload
         Patch merge: Schema target 71 changed to 101


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6404 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-08-02 23:44:15 +00:00
parent feca4b296a
commit 9f7c5d6443
10 changed files with 360 additions and 19 deletions

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>File Upload Form Sample</shortname>
<description>Form for uploading file content and meta-data into Repository</description>
<url>/sample/upload</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Upload Web Script Sample</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Upload Web Script Sample</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
</table>
<p>
<table>
<form action="${url.service}" method="post" enctype="multipart/form-data" charset="utf-8">
<tr><td>File:<td><input type="file" name="file">
<tr><td>Title:<td><input name="title">
<tr><td>Description:<td><input name="desc">
<tr><td><td>
<tr><td><td><input type="submit" name="submit" value="Upload">
</form>
</table>
</body>
</html>

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>File Upload Sample</shortname>
<description>Upload file content and meta-data into Repository</description>
<url>/sample/upload</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Upload Web Script Sample</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Upload Web Script Sample</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td>&nbsp;
<tr><td><td>Uploaded <a href="${url.serviceContext}/sample/folder${upload.displayPath}">${upload.name}</a> of size ${upload.properties.content.size}.
</table>
</body>
</html>

View File

@@ -0,0 +1,43 @@
var filename = null;
var content = null;
var title = "";
var description = "";
// locate file attributes
for each (field in formdata.fields)
{
if (field.name == "title")
{
title = field.value;
}
else if (field.name == "desc")
{
description = field.value;
}
else if (field.name == "file" && field.isFile)
{
filename = field.filename;
content = field.content;
}
}
// ensure mandatory file attributes have been located
if (filename == undefined || content == undefined)
{
status.code = 400;
status.message = "Uploaded file cannot be located in request";
status.redirect = true;
}
else
{
// create document in company home for uploaded file
upload = companyhome.createFile("upload" + companyhome.children.length + "_" + filename) ;
upload.properties.content.write(content);
upload.properties.content.mimetype = "UTF-8";
upload.properties.title = title;
upload.properties.description = description;
upload.save();
// setup model for response template
model.upload = upload;
}