Example 1: Upload a file to a remote repository
In this case, the server is composed of a single content repository. The CID process allows client applications to upload new files in the repository.
Server manifest⚓
<cid:manifest xmlns:cid="http://www.cid-protocol/schema/v1/core" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cid-protocol/schema/v1/core ../manifest/cid-core.xsd ">
<cid:process>
<cid:label xml:lang="fr">Téléversement de fichier</cid:label>
<cid:label xml:lang="en">File upload</cid:label>
<cid:meta name="File-name" is="http://purl.org/dc/elements/1.1/title">
<cid:label xml:lang="fr">Nom du fichier</cid:label>
<cid:label xml:lang="en">File name</cid:label>
<cid:doc xml:lang="en">
The file-name will be used in the public url of the file
Example: http://.../1d57fe87zr45sdz796m/monImage.png
</cid:doc>
</cid:meta>
<cid:meta name="Public-url" is="http://schema.org/URL"/>
<!--
The following fragment is the main part of the process declaration. It
describes each step of the process.
Each step declares the (previously-documented) used (optional), needed
or returned metadatas. This process contains only one step: the upload
step which is required to complete the file deposit and which is
composed by only one request (attribute step="unique"). This step
accepts the File-name metadata and returns the Public-url of the
uploaded file.
-->
<cid:upload url="http://example.com/upload.php" useMetas="File-name" returnMetas="Public-url" required="true"/>
</cid:process>
<!--
The second part of the manifest is dedicated to the enabled authentication
methods.
-->
<!--
The last part of the manifest is dedicated to the transport declaration.
In this example, the transport is a single HTTP request. The properties
attribute defines how the metadata should be sent.
The returned properties must be inserted in a single JSON object in the
body of the HTTP response.
-->
<cid:transports>
<cid:webTransport>
<cid:authentications>
<cid:basicHttp/>
</cid:authentications>
<cid:webUpload>
<cid:request method="GET" properties="header queryString"/>
<cid:request method="PUT" properties="header queryString"/>
<cid:request method="POST" properties="header queryString"/>
<cid:request method="POST;multipart/form-data" properties="header queryString post"/>
</cid:webUpload>
</cid:webTransport>
</cid:transports>
</cid:manifest>
The process step by step⚓
Procedure
Manifest exposition
The server must expose the XML manifest to an accessible URL. For example, at http://example.com/manifest.xml.
Download the manifest
In order to understand the process, a client must download the server manifest and analyze it.
Download the manifest Single upload
The client can now execute the defined step. In this case, the client must send the file in a single
HTTP
request following one of the valid transport descriptions of the manifest.For example, it could send the file in the body of a
PUT
request. TheFile-name
metadata could be sent in the header of the request. The body of the server response must be aJSON
object containing the returned metadata:Public-url
.Content upload