upload
API Support | Available since | Last updated | Output |
---|---|---|---|
5.9500 | 5.9500 | xml |
Description
Upload a single file to PageSeeder with the contents of the file in the body of the request.
If you need to upload multiple files at once, use /upload POST. However, when using autoload, you won’t be able to specify the title, description, document ID, or labels as parameters. Otherwise invoke this service multiple times with autoload=false
and then use Service: /members/{member}/groups/{group}/loadingzone/start [POST].
Administrators can upload on behalf of another member using the member parameter.
There are two modes of operation depending on whether the autoload parameter was used.
By default, the file is uploaded into the loading zone. When the autoload parameter is true
, the file is upload directly into the target folder of the specified group.
Some limitations are controlled by global properties:
- The maximum upload size is defined by the
maxUploadSize
global property. - The maximum number of attachments to a comment are defined by the
maxAttachmentNumber
global property. - The maximum number of workflow notifications is defined by the
maxWorkflowNotifications
global property.
Loading zone upload (default)
The loading zone is a temporary container for files on the server before they are loaded into PageSeeder.
There is a separate loading zone for each member on each group. Within a group a member can have multiple loading zones by specifying a unique uploadid or xlinkid for each one. An xlinkid is used to upload attachments to a draft comment before it is submitted (the xlinkid is the same as the comment ID).
After files have been uploaded, the various load services can be used to modify, unzip them and start loading them into PageSeeder.
Direct upload (autoload)
When autoload parameter is true
, the file is loaded directly into the target group and folder using a default configuration.
You can specify the target location using the url or the folder parameter. If neither is specified, the file is uploaded into the root folder of the group.
Use the overwrite-properties parameter if you want to update the title, description, document ID, labels, or metadata of the target URI if it exists. This parameter has no effect if overwrite is not set to true
. The title, description, docid, and labels can be specified as parameters on the request.
You cannot use autoload for attachments to comments, so specifying autoload=true
with an xlinkid parameter returns an error.
Parameters
Name | Description | Required | Type | Default |
---|---|---|---|---|
autoload | Whether the upload bypasses the loading zone | no | boolean | false |
description | The description of the file contained in the upload (autoload only) | no | string | |
docid | The document ID of the file contained in the upload (autoload only) | no | string | |
filename | The name of the file to upload (required if no X-File-Name header) | maybe | string | |
folder | The folder the files should be uploaded into (relative to the root of the group –autoload only, ignored if url is specified) | no | string | |
group | The name of the group the file should be uploaded into | yes | string | |
labels | A comma-separated list of labels to attach to the file contained in the upload (autoload only) | no | string | |
member | ID or username of a member to upload on behalf of (for admins only) | no | string | |
overwrite | Whether the uploaded file should overwrite an existing file (in loading zone and PageSeeder) | no | boolean | false |
overwrite-properties | Whether the uploaded file should overwrite existing URI properties (autoload only) | no | boolean | false |
title | The title of the file contained in the upload (autoload only) | no | string | |
uploadid | An ID to uniquely identify this upload (can be letters, numbers or hyphens up to 100 chars long, overrides xlinkid) | no | string | |
url | A URL pointing to the folder the files should be uploaded into (autoload only) | no | url | |
xlinkid | A comment ID used to build an upload ID (for comment attachments’ loading zone - no autoload). | no | long |
Permission
The permission required depends on the target context.
When attaching a file to a comment, the user must be a member of the group. Otherwise, the user must have edit permissions on the target folder (contributor and higher).
An Anti-CSRF-Token
token is required to use this service.
Response
The response depends on whether the autoload parameter was used.
Loading zone upload (default)
By default, this service returns the details of the file that was uploaded:
<upload member="[member ID]" [uploadid="[uploadid]"] max-workflow-notifications="20"> <file name="[filename]" path="[path]" type="file" ... /> </upload>
Direct upload
If autoload
is true
, this service returns the details of the URI created as a result of the upload in a <uri> element:
<upload member="[member ID]" [uploadid="[uploadid]" status="[failed|completed]"] max-workflow-notifications="20"> <message>[explanation or error]<message> <uri id="[uri id]" ... /> </upload>
Error handling
HTTP code | Error condition |
---|---|
400 | The file name is not specified using the X-File-Name HTTP header or the filename parameter |
400 | The parameter group is not specified or does not match an existing group |
400 | The selected destination folder or URL is invalid |
400 | The parameter xlinkid or uploadid is not valid. |
400 | The parameter member doesn’t match an existing member ID or username |
400 | Attempting to upload a PSML document to a comment (xlinkid parameter is specified and the filename ends with .psml) |
400 | Maximum number of files has been reached when attaching to a comment (default is 20) |
409 | Destination file already exists and overwrite parameter is set to false |
411 | HTTP header Content-Length is required |
413 | The content length exceeds the maximum upload size (default is 100MB) |