Developer:FilesResource

From myExperiment
Jump to: navigation, search

Files Resource

Index of files

URL: GET http://www.myexperiment.org/files.xml

Example output:

<?xml version='1.0' encoding='UTF-8'?>
<files>
  <file uri='http://www.myexperiment.org/file.xml?id=5' resource='http://www.myexperiment.org/files/5'>Viking boat</file>
  <file uri='http://www.myexperiment.org/file.xml?id=6' resource='http://www.myexperiment.org/files/6'/>
  <file uri='http://www.myexperiment.org/file.xml?id=7' resource='http://www.myexperiment.org/files/7'/>
  <file uri='http://www.myexperiment.org/file.xml?id=10' resource='http://www.myexperiment.org/files/10'>sample</file>
  <file uri='http://www.myexperiment.org/file.xml?id=11' resource='http://www.myexperiment.org/files/11'>pdf file test</file>
  ...
</files>


Create file

URL: POST http://www.myexperiment.org/file.xml

Example input:

<file>
  <title>Viking boat</title>
  <filename>boat.jpg</filename>
  <description><p>This boat is alongside the largest remaining section of Southampton's city wall, next to the Grand Harbour hotel. The sand and blue coloured stone sections on the ground represent the original beach and waterline before the land was reclaimed.</p></description>
  <content-type>image/pjpeg</content-type> 
  <content encoding="base64" type="binary">
    /9j/4AAQSkZJRgABAQAAAQABAAD//gAoCgoKMTIvMDMvMjAwNgoxNjoxOTo0
    MgpNb2RlPTEKMC4xCjMuMAr/2wBDAA4KCw0LCQ4NDA0QDw4RFiQXFhQUFiwg
    IRokNC43NjMuMjI6QVNGOj1OPjIySGJJTlZYXV5dOEVmbWVabFNbXVn/2wBD
    AQ8QEBYTFioXFypZOzI7WVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZ
    WVlZWVlZWVlZWVlZWVlZWVlZWVn/wAARCAHgAoADASIAAhEBAxEB/8QAHwAA 
    ....
  </content> 
  <license-type>by-nd</license-type>
</file>


Example output:

<?xml version="1.0" encoding="UTF-8" ?> 
<file uri="http://www.myexperiment.org/file.xml?id=5" resource="http://www.myexperiment.org/files/5">
  <id>5</id>
  <filename>boat.jpg</filename>
  <title>Viking boat</title> 
  <description>&lt;p&gt;This boat is alongside the largest remaining section of Southampton's city wall, next to the Grand Harbour hotel. The sand and blue coloured stone sections on the ground represent the original beach and waterline before the land was reclaimed.&lt;/p&gt;</description> 
  <uploader uri="http://www.myexperiment.org/user.xml?id=22" resource="http://www.myexperiment.org/users/22">Don Cruickshank</uploader> 
  <content-type>image/pjpeg</content-type> 
  <created-at>Wed Nov 07 11:46:06 +0000 2007</created-at> 
  <license-type>by-nd</license-type> 
  <tags/>
</file>

Note: If the MIME-type specified in "content-type" field is used in multiple content types, a 400 error will be returned. To resolve this, specify a "type" instead.

For example, if the following "content-type" field returns an error:

<content-type>text/xml</content-type>

Look up a list of Content Types registered with that MIME-type here http://www.myexperiment.org/content_types?mime_type=text/xml and enter the title of the Content Type you wish to use in the "type" field, and remove the "content-type" field.

<type>XML</type>


Read file

URL: GET http://www.myexperiment.org/file.xml?id=5

Example output:

<?xml version="1.0" encoding="UTF-8" ?> 
<file uri="http://www.myexperiment.org/file.xml?id=5" resource="http://www.myexperiment.org/files/5">
  <id>5</id> 
  <filename>boat.jpg</filename>
  <title>Viking boat</title> 
  <description>&lt;p&gt;This boat is alongside the largest remaining section of Southampton's city wall, next to the Grand Harbour hotel. The sand and blue coloured stone sections on the ground represent the original beach and waterline before the land was reclaimed.&lt;/p&gt;</description> 
  <uploader uri="http://www.myexperiment.org/user.xml?id=22" resource="http://www.myexperiment.org/users/22">Don Cruickshank</uploader> 
  <content-type>image/pjpeg</content-type> 
  <created-at>Wed Nov 07 11:46:06 +0000 2007</created-at> 
  <updated-at>Wed Feb 06 12:02:05 +0000 2008</updated-at> 
  <license-type>by-nd</license-type> 
  <tags>
    <tag uri="http://sandbox.myexperiment.org/tag.xml?id=626" resource="http://sandbox.myexperiment.org/tags/626">boat</tag>
  </tags>
</file>

Update file

URL: PUT http://www.myexperiment.org/file.xml?id=5

Example input:

<file>
  <title>Viking boat in Southampton</title>
  <description><p>This boat is alongside the largest remaining section of Southampton's city wall, next to the Grand Harbour hotel. The sand and blue coloured stone sections on the ground represent the original beach and waterline before the land was reclaimed.</p></description>
  <content-type>image/pjpeg</content-type> 
  <license-type>by-nd</license-type>
</file>


Example output:

<?xml version="1.0" encoding="UTF-8" ?> 
<file uri="http://www.myexperiment.org/file.xml?id=5" resource="http://www.myexperiment.org/files/5">
  <id>5</id>
  <filename>boat.jpg</filename>
  <title>Viking boat in Southampton</title> 
  <description>&lt;p&gt;This boat is alongside the largest remaining section of Southampton's city wall, next to the Grand Harbour hotel. The sand and blue coloured stone sections on the ground represent the original beach and waterline before the land was reclaimed.&lt;/p&gt;</description> 
  <uploader uri="http://www.myexperiment.org/user.xml?id=22" resource="http://www.myexperiment.org/users/22">Don Cruickshank</uploader> 
  <content-type>image/jpeg</content-type> 
  <created-at>Wed Nov 07 11:46:06 +0000 2007</created-at> 
  <license-type>by-nd</license-type> 
  <tags>
    <tag uri="http://sandbox.myexperiment.org/tag.xml?id=626" resource="http://sandbox.myexperiment.org/tags/626">boat</tag>
  </tags>
</file>


Delete file

URL: DELETE http://www.myexperiment.org/file.xml?id=5

Example output:

<?xml version="1.0" encoding="UTF-8" ?> 
<file uri="http://www.myexperiment.org/file.xml?id=5" resource="http://www.myexperiment.org/files/5">
  <id>5</id> 
  <filename>boat.jpg</filename>
  <title>Viking boat</title> 
  <description>&lt;p&gt;This boat is alongside the largest remaining section of Southampton's city wall, next to the Grand Harbour hotel. The sand and blue coloured stone sections on the ground represent the original beach and waterline before the land was reclaimed.&lt;/p&gt;</description> 
  <uploader uri="http://www.myexperiment.org/user.xml?id=22" resource="http://www.myexperiment.org/users/22">Don Cruickshank</uploader> 
  <content-type>image/pjpeg</content-type> 
  <created-at>Wed Nov 07 11:46:06 +0000 2007</created-at> 
  <updated-at>Wed Feb 06 12:02:05 +0000 2008</updated-at> 
  <license-type>by-nd</license-type> 
  <tags>
    <tag uri="http://sandbox.myexperiment.org/tag.xml?id=626" resource="http://sandbox.myexperiment.org/tags/626">boat</tag>
  </tags>
</file>


Elements for file

  • id - the id of the file
  • filename - the filename of the uploaded file
  • title - the title of the file
  • description - a description of the file
  • type - the content type resource that describes the type of the file
  • uploader - the user that uploaded the file
  • content-type - the mime type of the file
  • content - contents of the uploaded file encoded in base64
  • created-at - the date/time the file was created (uploaded)
  • updated-at - the date/time the file was last modified
  • license-type - the license resource that describes the licensing of the file
  • credits - a list of users/groups credited for the creation (intellectual property) of the file
  • attributions - a list of workflows/files to which the file attributes its creation
  • tags - a list of tag resources describing the file
  • taggings - a list of tagging resources (i.e. resources that describe tag resources in the context of the file)
  • privileges - a list of access privileges the user requesting the file has for the resource
  • statistics - total viewings and downloads for the file, including a further breakdown into those accessed directly from the site and those accessed in other ways (e.g. Taverna plugin)