Updating Data

Files

The API supports uploading one or more files with the same request. The files can be uploaded to a given category, or as an uncategorized file. There exists a helper function to receive all the categories for a given project

Get file and category info

Get project file categories

Deprecated: Starting from version 0.34, there is no longer a need to go through project in order to access file categories. Use this instead

Fetch an array of valid project file categories.

URI: https://<im4>/project/{projectId}/files/categories
  • Request-type: GET
  • Parameters:{projectId} (part of URI): ID of the project
  • Return data: {categories} (JSON)

Get files in project file category

Fetch an array of files in given project file category.

URI: https://<im4>/project/{projectId}/files/category/{categoryId}
?include_details={true?}
&include_size={true?}
&include_filter={true?}
  • Request-type: GET
  • Parameters:
    {projectId} (part of URI): ID of the project
    {categoryId} (part of URI): ID of category
    {include_details}(boolean): includes more metadata + preview url
    {include_size} (boolean): includes width and height of image
    {include_filter} (boolean): includes used filter if any and if file can have filter applied
  • Return data: {files} (JSON)

Get all project files

Fetch an array of files in given project file category.

URI: https://<im4>/project/{projectId}/files/all
?include_details={true?}
  • Request-type: GET
  • Parameters:
    {projectId} (part of URI): ID of the project
    {include_details} (boolean): gives more metadata + preview url
  • Return data: {files} (JSON)

If a file has property queued set, the file is currently processed by a background process. The property queue will then tell what kind of process file is process by.
Queue = upload is an initial processing of images at upload.
Queue = pfc is image improvement or color filtering queue.

queue and queued are included both with or without the ?include_details property set.

Download

Download files in project file category

Fetch all files in given project file category.

URI: https://<im4>/project/{projectId}/files/category/{categoryId}/download
  • Request-type: GET
  • Parameters:
    {projectId} (part of URI): ID of the project
    {categoryId} (part of URI): ID of category
  • Return data:{files} downloaded resource file(s)

If there is only one file, it will be downloaded directly, otherwise a zip-file will be generated:

Download all project files

Fetch all files in project.

URI: https://<im4>/project/{projectId}/files/all/download
  • Request-type: GET
  • Parameters: {projectId} (part of URI): ID of the project
  • Return data:{files} downloaded resource file(s)

Upload

The function for uploading files to a project accepts an array of files given as multipart/form-data:

Upload file to a project file category

Uploads files to given project and category.

URI: https://<im4>/project/{projectId}/files/category/{categoryId}
  • Request-type: POST
  • Parameters:
    {projectId} (part of URI): ID of the project
    {categoryId} (part of URI): ID of category - provide 0 to set file as uncategorized
    {includeFailed} (part of URI): {bool|optional} - gives different result including info about failed files {files}: array of files as multipart/form-data
  • Return data:

If includeFailed is set to true - this json object is returned:

{
  "uploaded_file_ids": [1, 2, 3],
  "failed": [
    {
      "message": "Errormessage",
      "filename": "Image.jpg"
    }
  ]
}

If includeFailed is set to false or not included - only an array of file_ids is returned:

[1, 2, 3]

Sort files

Sort files in project by specifying file ids in correct order.

URI: https://<im4>/project/{projectId}/files/sortorder/{file_ids}
  • Request-type: POST
  • Parameters:
    {projectId} (part of URI): ID of the project
    {file_ids} (part of URI): File ids in wanted order
  • Return data:{mixed} (JSON): file_id and new sortcode

Set metadata and category

Set metadata and category on files Since: 0.20

URI: https://<im4>/project/{projectId}/files/{file_ids}/set-metadata
  • Request-type: POST
  • Parameters:
    {projectId} (part of URI): ID of the project
    {file_ids} (part of URI): File ids
    {caption} (string): picture caption
    {byline} (string): second picture caption – used for flower greetings
    {priority} (integer): setting priority for image (0,1,2)
    {category_id} (integer): setting image category