Skip to content
Mark Hamstra edited this page Aug 15, 2017 · 9 revisions

Rest Endpoints

Route HTTP Verb Description
/media/sources GET Retrieve a list of media sources
/media/sources/:source GET Retrieve a list of top–level directories of a given media source
/media/sources/:source?path=assets%2Fimg GET Retrieve a list of media items and subdirectories of a given directory of a given media source
/media/sources/:source?path=assets%2Fimg%2Fturtle.jpg DELETE Delete a given media item of a given media source
/media/sources/:source?path=assets%2Fimg POST Upload files to a given directory of a given media source
/media/sources/:source?path=assets%2Fimg%2turtle.jpg&name=sea.jpg PUT Rename a given media item of a given media source
/media/sources/:source?path=assets%2Fimg&name=images PUT Rename a given directory of a given media source
/media/sources/:source?path=assets%2Fimg%2Fbackgrounds PUT Creates a directory at the given name
/media/attachments/:source POST Serve a zip file build from posted form data with cd, cs, and list of zip-files[]

Todo

  • Configurable base URL, ie: core/components/eureka
  • sync forms (form data endpoints rather than URL params)

Example Responses

Retrieve a list of media sources GET /media/sources

[
  {"name":"filesystem", "id":0},
  {"name":"s3", "id":1}
]

Retrieve a list of top–level directories of a given media source GET /media/sources/:source

[
  {"name":"assets","cd":"assets"},
  {"name":"foo","cd":"foo"}
]

To improve the user experience, you may recursively return as many "children" subdirectories as you like. This will allow users to more effortlessly browse as directories become available sooner.

[
   {
      "name":"assets",
      "cd":"assets",
      "children":[
         {
            "name":"img",
            "cd":"assets/img",
            "children":[
               {
                  "name":"hawaii",
                  "cd":"assets/img/hawaii"
               },
               {
                  "name":"redwoods",
                  "cd":"assets/img/redwoods"
               }
            ]
         },
         {
            "name":"screenshots",
            "cd":"assets/screenshots"
         },
         {
            "name":"uploads",
            "cd":"assets/uploads"
         }
      ]
   },
   {
      "name":"foo",
      "cd":"foo"
   }
]

Retrieve a list of media items and subdirectories of a given directory of a given media source GET /media/sources/:source?path=assets%2Fimg

[
   {
      "filename":"DSC02469.jpg",
      "directory":"assets/img/",
      "path":"/sources/filesystem/assets/img/DSC02469.jpg",
      "alt": "An adult turtle laying in the sand",
      "absoluteURL":"/sources/filesystem/assets/img/DSC02469.jpg",
      "editedOn":"2017-02-16T04:44:07.000Z",
      "dimensions":[
         163,
         42
      ],
      "fileSize":36335
   },
   {
      "foldername":"hawaii",
      "directory":"assets/img/hawaii",
      "path":"/sources/filesystem/assets/img/hawaii",
      "absoluteURL":"/sources/filesystem/assets/img/hawaii",
      "editedOn":"2017-03-12T23:22:59.000Z"
   },
   {
      "foldername":"redwoods",
      "directory":"assets/img/redwoods",
      "path":"/sources/filesystem/assets/img/redwoods",
      "absoluteURL":"/sources/filesystem/assets/img/redwoods",
      "editedOn":"2017-02-20T08:46:06.000Z"
   }
]

Delete a given media item of a given media source

DELETE /media/sources/:source?path=assets%2Fimg%2Fturtle.jpg

true

Upload files to a given directory of a given media source

POST /media/sources/:source?path=assets%2Fimg

Send files as FormData of body of request. The response will contain a fresh list of subdirectories and media items of path once the items have been uploaded

[
   {
      "filename":"Love_What_You_Do_print_04_web.jpg",
      "directory":"assets/img",
      "path":"/sources/filesystem/assets/img/Love_What_You_Do_print_04_web.jpg",
      "absoluteURL":"/sources/filesystem/assets/img/Love_What_You_Do_print_04_web.jpg",
      "editedOn":"2017-03-13T15:02:55.000Z",
      "dimensions":[
         252,
         120
      ],
      "fileSize":870377
   },
   {
      "filename":"digital_thumb.png",
      "directory":"assets/img",
      "path":"/sources/filesystem/assets/img/digital_thumb.png",
      "absoluteURL":"/sources/filesystem/assets/img/digital_thumb.png",
      "editedOn":"2017-03-13T15:02:55.000Z",
      "dimensions":[
         84,
         94
      ],
      "fileSize":26122
   },
   {
      "filename":"digital_thumb_landscape.png",
      "directory":"assets/img",
      "path":"/sources/filesystem/assets/img/digital_thumb_landscape.png",
      "absoluteURL":"/sources/filesystem/assets/img/digital_thumb_landscape.png",
      "editedOn":"2017-03-13T15:02:55.000Z",
      "dimensions":[
         232,
         54
      ],
      "fileSize":32052
   },
   {
      "foldername":"hawaii",
      "directory":"assets/img/hawaii",
      "path":"/sources/filesystem/assets/img/hawaii",
      "absoluteURL":"/sources/filesystem/assets/img/hawaii"
   },
   {
      "foldername":"redwoods",
      "directory":"assets/img/redwoods",
      "path":"/sources/filesystem/assets/img/redwoods",
      "absoluteURL":"/sources/filesystem/assets/img/redwoods"
   }
]

Rename a given media item of a given media source

PUT /media/sources/:source?path=assets%2Fimg%2turtle.jpg&name=sea.jpg

Return a fresh listing of the entire directory.

[
   {
      "filename":"DSC02525.jpg",
      "directory":"/sources/filesystem/assets/img/hawaii",
      "path":"/sources/filesystem/assets/img/hawaii/DSC02525.jpg",
      "absoluteURL":"/sources/filesystem/assets/img/hawaii/DSC02525.jpg",
      "editedOn":"2017-02-16T04:44:09.000Z",
      "dimensions":[
         282,
         162
      ],
      "fileSize":41545
   },
   {
      "filename":"sea.jpg",
      "directory":"/sources/filesystem/assets/img/hawaii",
      "path":"/sources/filesystem/assets/img/hawaii/sea.jpg",
      "absoluteURL":"/sources/filesystem/assets/img/hawaii/sea.jpg",
      "editedOn":"2017-02-16T04:44:09.000Z",
      "dimensions":[
         192,
         107
      ],
      "fileSize":34178
   }
]

Rename a given directory of a given media source PUT /media/sources/:source?path=assets%2Fimg&name=images