Update media
/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 repsitory.
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
- multipart/form-data
object
MediaImport
-
mediaItems(optional):
array 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.
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.
-
Array of:
object MediaItem
Title:
MediaItem
object
MediaItem
-
errorMessage(optional):
string
Contains error messages if request for this file was unsucessful
-
fileName(optional):
string
The name of the file
-
relativePath(optional):
string
Relative path under the repository to place image in
-
resourceURL(optional):
string
Relative path to image stored in the repository
-
thumbnailURL(optional):
string
Relative path to thumbnail image stored in the repository
Response
- application/json
- application/xml
200 Response
object
ResultList MediaItem
-
allOf
Collection Paging Resource
Title:
Collection Paging Resource
Oracle base collection resource schema definition. -
object
ResultList MediaItem-allOf[1]
Collection Paging Resource
-
allOf
Base Collection Resource
Title:
Base Collection Resource
Oracle base collection resource schema definition. -
object
Collection Paging Resource-allOf[1]
Base Collection Resource
-
object
Singular Resource
Title:
Singular Resource
Oracle base singular resource schema definition. -
object
Base Collection Resource-allOf[1]
object
Singular Resource
object
-
count(optional):
integer
Number of resource instances returned in the current range.
-
hasMore(optional):
boolean
Boolean value that is set to true if more resources are available on the server than the subset returned in current page.
-
limit(optional):
integer
Actual paging size used by the server.
-
offset(optional):
integer
Offset value used in the current page.
-
totalResults(optional):
integer
Total count of the resource instances, including both the instances in the current range and the instances on the server that satisfy the request.
array
-
Array of:
object instanceLink
Metadata describing link description objects that MAY appear in the JSON instance representation.
object
-
href:
string
URI [RFC3986] or URI Template [RFC6570]. If the value is set to URI Template, then the "templated" property must be set to true.
-
mediaType(optional):
string
Media type, as defined by RFC 2046, describing the link target.
-
method(optional):
string
HTTP method for requesting the target of the link.
-
profile(optional):
string
Link to the metadata of the resource, such as JSON-schema, that describes the resource expected when dereferencing the target resource..
-
rel:
string
Name of the link relation that, in addition to the type property, can be used to retrieve link details. For example, href or profile.
-
templated(optional):
boolean
Boolean flag that specifies that "href" property is a URI or URI Template. If the property is a URI template, set this value to true. By default, this value is false.
object
object
MediaItem
-
errorMessage(optional):
string
Contains error messages if request for this file was unsucessful
-
fileName(optional):
string
The name of the file
-
relativePath(optional):
string
Relative path under the repository to place image in
-
resourceURL(optional):
string
Relative path to image stored in the repository
-
thumbnailURL(optional):
string
Relative path to thumbnail image stored in the repository
Examples
The following example shows how to upload a list of media files into the Oracle Knowledge repository by submitting a PUT request on the REST resource using cURL.
cURL Command Example
curl -X "PUT" "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 }