Store an Object
/mobile/platform/storage/collections/{collection}/objects
This operation enables you to store an object and have an identifier automatically assigned to it.
Example
The following example stores the contents of the file called myObj1.jpeg
in the collection called myCollection
. The URL that you use to access this object is returned in the Location
HTTP response header.
curl -X POST -H "Authorization" -H "Content-Length 4321" -H "Content-Type: image/jpeg" -d @myObj1.jpeg {HOST}/mobile/platform/storage/collections/myCollection/objects
Permissions
- Anonymous Access: If the following are true, then you can access this operation anonymously or as any user, regardless of assigned roles.
- The backend allows anonymous access.
- The
Security_CollectionsAnonymousAccess
environment policy lists the collection. - The collection is shared
- Role-Based Access:
- You must have been granted one of the following permissions to the collection:
READ_WRITE
READ_WRITE_ALL
- If the backend doesn't allow anonymous access, then you must be a member of the realm that's associated with the mobile backend.
- You must have been granted one of the following permissions to the collection:
Request
- */*
-
collection: string
The name of the collection that you want to access.
When you look at the metadata for the collection, this parameter corresponds to the
id
value:{ "id": "pictures", "description": "Application images", "contentLength": 6205619, "eTag": "\"1.0\"", "links": [ { "rel": "canonical", "href": "/mobile/platform/storage/collections/images" }, { "rel": "self", "href": "/mobile/platform/storage/collections/images" } ] }
-
user(optional): string
This is the ID (not the user name) of a user. This query parameter allows a user with
READ_ALL
orREAD_WRITE_ALL
permission to access the isolated space of the user identified by the ID. Users who haveREAD
orREAD_WRITE
permission can access only their own space. If you storing an object in an isolated collection, and you haveREAD_ALL
orREAD_WRITE_ALL
permission, then the signed-in user is assumed unless you include this property. If you haveREAD_ALL
orREAD_WRITE_ALL
permission for an isolated collection, then you must include this property to store objects in another user's space.
-
Accept(optional): string
The media types that the client prefers for the response body. If the service doesn't support any of these types, then it returns a
406
status code, and the response body lists the media types that it supports.Examples
*/*
application/*
application/json
application/xml,application/json
-
Content-Length(optional): number
The size of the object in bytes.
-
Content-Type(optional): string
The media type of object being stored. This is the same media type that is returned when the object is requested.
-
Oracle-Mobile-Name(optional): string
The display name for the object. If you don't include the display name, the name is set to the object identifier that the
POST
operation generates automatically or the identifier that you supplied to thePUT
operation using the{object}
path parameter.Example - With Oracle-Mobile-Name
If you include the
Oracle-Mobile-Name
header in yourPUT
request, like the following example:curl -X PUT {AUTHENTICATION HEADERS} -H "Content-Length 4321" -H "Content-Type: image/jpeg" -H "Oracle-Mobile-NAME: Banner" -d @myObj1.jpeg {HOST}/mobile/platform/storage/collections/myCollection/objects/myObj1
Then the object's name is set to to
Oracle-Mobile-Name
HTTP request header value:{ "id" : "myObj1", "name" : "Banner", "links" : { .... } }
Example - Without Oracle-Mobile-Name
If you don't include the
Oracle-Mobile-Name
header in yourPUT
request, like the following example:curl -X PUT {AUTHENTICATION HEADERS} -H "Content-Length 4321" -H "Content-Type: image/jpeg" -d @myObj1.jpeg {HOST}/mobile/platform/storage/collections/myCollection/objects/myObj1
Then the object's name will be the same value as its ID.
{ "id" : "myObj1", "name" : "myObj1", "links" : { .... } }
- */*
Response
- application/json
201 Response
Created
The object was created successfully in the specified collection.
-
Location: string
The URI that corresponds to the newly created object.
object
Object
-
contentLength(optional):
integer
The size of object in bytes.
-
contentType(optional):
string
Maximum Length:
255
The media type of the object. For example, a JPEG image would have a media type of image/jpeg. -
createdBy(optional):
string
The user name for the user who created the object.
-
createdOn(optional):
string
The date and time, in ISO 8601 format, that the object was created (for example, 2014-06-30T01:02:03Z).
-
eTag(optional):
string
An identifier that was assigned to this version of the object. This value changes whenever the object is updated. The value includes the starting and ending quotation marks (for example, "2"). You can use an ETag value with the `IF-MATCH` and `IF-NONE-MATCH` HTTP request headers.
-
id(optional):
string
Minimum Length:
1
Maximum Length:1024
The object's unique identifier. This is the value that is used in the URI to access the object. -
links(optional):
array links
Minimum Number of Items:
0
The links that you can use to explore the resource. -
modifiedBy(optional):
string
The user name for the user who last modified the object.
-
modifiedOn(optional):
string
The date and time, in ISO 8601 format, that the object was last modified (for example, 2014-06-30T01:02:03Z).
-
name(optional):
string
Maximum Length:
1024
The display name for the object. -
user(optional):
string
For user-isolated collections, the ID of the user that the object belongs to.
array
0
-
Array of:
object Link
Title:
Link
object
Link
-
href:
string
A relative URL.
-
rel:
Allowed Values:
[ "self", "canonical", "prev", "next" ]
The type of link.
{
"eTag":"\"1\"",
"id":"a95edb6f-539d-4bac-9ffa-78ff16b20516",
"createdOn":"2014-11-20T15:53:05Z",
"modifiedOn":"2014-11-20T15:53:05Z",
"createdBy":"jdoe",
"modifiedBy":"jdoe",
"name":"Profile Picture",
"links":[
{
"rel":"canonical",
"href":"/mobile/platform/storage/collections/pictures/objects/a95edb6f-539d-4bac-9ffa-78ff16b20516"
},
{
"rel":"self",
"href":"/mobile/platform/storage/collections/pictures/objects/a95edb6f-539d-4bac-9ffa-78ff16b20516"
}
],
"contentType":"image/png",
"contentLength":937647
}
400 Response
Bad Request
This status is returned if you attempt to:
- Make a call without specifying the
Oracle-Mobile-Backend-ID
HTTP request header. - Specify the
user
query parameter for an endpoint that isn't an object level operation for an isolated collection. - Specify an incorrect value for a query parameter.
- Store an object with an identifier longer than the maximum allowed size.
- Store an object where the actual size of the object is different from what was specified in the
Content-Length
HTTP request header.
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
401 Response
Unauthorized
The user is not authenticated. The request must be made with the Authorization
HTTP request header.
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
403 Response
Forbidden
This status is returned if you attempt to:
- Make a request with a user from a realm that isn't associated with the mobile backend.
- Retrieve an object without being assigned a role that has
READ
orREAD_WRITE
access for the collection. - Retrieve an object from your isolated space without being assigned a role that has
READ
,READ_WRITE
,READ_ALL
, orREAD_WRITE_ALL
access for the collection. - Retrieve an object from another user's isolated space without being assigned a role that has
READ_ALL
orREAD_WRITE_ALL
access for the collection. - Store an object without being assigned a role that has been granted
READ_WRITE
access for the collection. - Store an object to your isolated space without being assigned a role that has
READ_WRITE
orREAD_WRITE_ALL
access for the collection. - Store an object to another user's isolated space without being assigned a role that has
READ_WRITE_ALL
access for the collection.
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
404 Response
Not Found
A collection with the given identifier does not exist.
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
406 Response
Not Acceptable
The media type of the resource isn't compatible with the values in the Accept
header.
For example, you see this error when you try to request a resource that has the media type application/json
and the Accept
header value is application/xml
.
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
411 Response
Length Required
The PUT
or POST
HTTP request to store an object into a collection is missing either the Content-Length
or the Transfer-Encoding
header.
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
413 Response
Request Entity Too Large
This status is returned when you attempt to store an object that is bigger than 2147483647
bytes (approx 2GB).
object
Error
-
detail:
string
Message that provides the error details.
-
o:ecid:
string
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorDetails(optional):
array o:errorDetails
Minimum Number of Items:
0
List of the issues that cause the error. Included when the error is caused by multiple issues. -
o:errorPath:
string
The relative point in the API path where the error occurred.
-
status:
integer
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
array
0
-
Array of:
object Error Detail
Title:
Error Detail
object
Error Detail
-
instance:
string
The URI to the link that provides more detailed information about the error.
-
o:errorCode:
string
Mobile Cloud Service error code.
-
o:errorPath:
string
The relative point in the API path where the error occurred.
-
title:
string
Summary of the problem.
-
type:
string
The URI to the link that provides details about the HTTP status code.
Examples
This example shows how to use cURL to add a file to a collection by submitting a POST request on the REST resource. In the example, the file TN062415Cust43.txt
is stored in the technicianNotes
collection.
curl -i \
-X POST \
-u mobile.user@example.com:password \
-d @TN062415Cust43.txt \
-H "Content-Length: 59" \
-H "Content-Type: text/plain" \
-H "Oracle-Mobile-Backend-ID: ABCD9278-091f-41aa-9cb2-184bd0586fce" \
https://fif.cloud.oracle.com/mobile/platform/storage/collections/technicianNotes/objects
Example of Response Header
Here's an example of the response header:
201 CREATED
Content-Length: 621
Content-Type: application/json
Date: Thu, 29 Mar 2018 21:43:46 GMT
Location: https://fif.cloud.oracle.com/mobile/platform/storage/collections/technicianNotes/objects/947119e5-b45c-498b-a643-dca279b24f07?user=8c8f1a5a-e56b-494b-9a99-f03d562c1ee7
Example of Response Body
This example shows the contents of the response body in JSON format:
{
"id": "947119e5-b45c-498b-a643-dca279b24f07",
"name": "947119e5-b45c-498b-a643-dca279b24f07",
"user": "8c8f1a5a-e56b-494b-9a99-f03d562c1ee7",
"contentLength": 59,
"contentType": "text/plain",
"eTag": "\"1\"",
"createdBy": "mobileuser",
"createdOn": "2015-06-24T02:59:08Z",
"modifiedBy": "mobileuser",
"modifiedOn": "2015-06-24T02:59:08Z",
"links": [
{
"rel": "canonical",
"href": "/mobile/platform/storage/collections/technicianNotes/objects/947119e5-b45c-498b-a643-dca279b24f07?user=8c8f1a5a-e56b-494b-9a99-f03d562c1ee7"
},
{
"rel": "self",
"href": "/mobile/platform/storage/collections/technicianNotes/objects/947119e5-b45c-498b-a643-dca279b24f07"
}
]
}