Create media

post

/km/api/v1/media

This method uploads the list of files into the repository. If the file being uploaded is of png jpeg bmp or gif type, a thumbnail version of the image will also be created in the repository.

The Accept header for this call should be multipart/form-data.

Duplicate entries of the same relative path and filename combination will be ignored if present in the MediaItem list in the mediaImportBO

If there are multiple files that have the same filename but are actually different in content in the filesToUpload portion then the method will only use one of the files. It is possible however, to place the same file into multiple different relativePath locations.

To place the file being uploaded at the repository root view, provide an empty relativePath in the MediaItemBO.

To place the file being uploaded at a specific view provide the name of the view as the relativePath.

The active user must have rights to the view in order to upload images. It is also possible to create folder(s) underneath the view by providing the relativePath as follows : NameOfView/folderName.

To include an inline image in content take the values seen in the resourceURL and thumbnailURL fields of the MediaItemBO and use it in the content xml as the src value of the img tag.

Response Errors

The possible error responses for this method are as follows:

  • OK-FMS0013

    The error occurs when you the number of files to upload exceeds the configured maximum value in the repository, default value is 500 files.

  • OK-FMS0006

    The error occurs when the filesToUpload portion of the multipart form data is missing.

  • OK-GEN0031

    The error occurs when you don't provide a list of mediaItemBOs in the mediaImportBO

  • OK-SEC0006

    The error occurs when you try to upload a file with a MIME type mismtach.

  • OK-FMS0016

    The error occurs when you try to upload a file with an extension that is not allowed.

  • OK-FMS0020

    The error occurs when a filename specified in the list of mediaItemBO doesn't match any of the filenames in the multipart binary files.

  • OK-FMS0017

    The error occurs when filename is longer than 100 characters.

  • OK-FMS0018

    The error occurs when filename or relativePath contains disallowed characters. The relativePath and filename may not contain : ? * ' < > | characters. The relativePath may not start with a / character and cannot contain // /// or \ characters. The filename may not contain / or \ characters.

Request

Supported Media Types
Body ()
MediaImport contains list of MediaItems to be uploaded
Root Schema : MediaImport
Type: object
Title: MediaImport
Show Source
  • mediaItems

    The views assigned to the content. The user who has the view assigned to the content or the content type in which the content is saved can only access the content.

Nested Schema : mediaItems
Type: array

The views assigned to the content. The user who has the view assigned to the content or the content type in which the content is saved can only access the content.

Show Source
Nested Schema : MediaItem
Type: object
Title: MediaItem
Show Source
Back to Top

Response

Supported Media Types

200 Response

OK.
Body ()
Root Schema : ResultList MediaItem
Type: object
Title: ResultList MediaItem
Match All
Show Source
Nested Schema : Collection Paging Resource
Title: Collection Paging Resource
Oracle base collection resource schema definition.
Match All
Show Source
Nested Schema : Base Collection Resource
Title: Base Collection Resource
Oracle base collection resource schema definition.
Match All
Show Source
Nested Schema : Singular Resource
Type: object
Title: Singular Resource
Oracle base singular resource schema definition.
Show Source
Nested Schema : Base Collection Resource-allOf[1]
Type: object
Show Source
Nested Schema : Collection Paging Resource-allOf[1]
Type: object
Show Source
Nested Schema : ResultList MediaItem-allOf[1]
Type: object
Show Source
Nested Schema : items
Type: array
Show Source
Nested Schema : items
Type: object
Nested Schema : items
Type: array
Show Source
Nested Schema : MediaItem
Type: object
Title: MediaItem
Show Source
Back to Top

Examples

The following example shows how to upload a list of media files into the Oracle Knowledge repository by submitting a POST request on the REST resource using cURL.

cURL Command Example

curl -X "POST" "http://<IM_REST_API_HOST>/km/api/latest/media

Example of Request Header

The following shows an example of the request header.

-H "kmauthtoken: {\"siteName\":\"ORACLE_KNOWLEDGE\",\"integrationUserToken\":\"\"+eCJYkxKwj5HUaIiJYun0/TpatwT1LmtcsF05W33xnEojifV/AsLDj9RpN0lKuorTMNKeSE1tgC7svVL+BzntqDON4KiM1HFlpxvXEUCB0P2w0Xrs75McygqxdVaDSE9",\"userToken\":\"UoyWTKRG4RpyJCH4Wqjzht2iYUrsDdk5ir+3IpwEkxcwajJkGR9OGSQBTANQVGW0iVT9MFeDzqL+RYdgfzGSK+h5QzDFIDM+rDLgdKeEE19ljWFm3zMCF+kgYp/dJ/Yq5V7Re+aDXqHg6YkHfvprFA==\"}" \
-H "Accept: application/json"

Request Body Example

The following shows an example of the request body.

{
  "mediaItems" : [ {
    "fileName" : "FILENAME_VALUE",
    "relativePath" : "RELATIVEPATH_VALUE",
    "resourceURL" : "RESOURCEURL_VALUE",
    "thumbnailURL" : "THUMBNAILURL_VALUE",
    "errorMessage" : "ERRORMESSAGE_VALUE"
  } ]
}

Response Body Example

The following shows an example of the response body in JSON format.

{
  "items" : [ {
    "fileName" : "FILENAME_VALUE",
    "relativePath" : "RELATIVEPATH_VALUE",
    "resourceURL" : "RESOURCEURL_VALUE",
    "thumbnailURL" : "THUMBNAILURL_VALUE",
    "errorMessage" : "ERRORMESSAGE_VALUE"
  }, {
    "fileName" : "FILENAME_VALUE",
    "relativePath" : "RELATIVEPATH_VALUE",
    "resourceURL" : "RESOURCEURL_VALUE",
    "thumbnailURL" : "THUMBNAILURL_VALUE",
    "errorMessage" : "ERRORMESSAGE_VALUE"
  }, {
    "fileName" : "FILENAME_VALUE",
    "relativePath" : "RELATIVEPATH_VALUE",
    "resourceURL" : "RESOURCEURL_VALUE",
    "thumbnailURL" : "THUMBNAILURL_VALUE",
    "errorMessage" : "ERRORMESSAGE_VALUE"
  } ],
  "hasMore" : false,
  "limit" : 20,
  "offset" : 0,
  "count" : 3
}
Back to Top