Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The DocumentDB API supports basic CRUD operations on the resources under a database account. This topic outlines the REST operations used to manage DocumentDB attachments.
Attachments are special documents that contain references and associated metadata with an external blob or media file.
Developers can choose to have:
The attachment media/blob managed by DocumentDB or
Store it with an external blob service provider such as OneDrive, Dropbox, etc. and store the reference metadata for attachment in DocumentDB.
Note
Attachments are a preview feature in DocumentDB and has small limits for experimentation and development. For attachment storage quota information, see DocumentDB limits.
The attachment resource is represented by attachments in the DocumentDB REST resource model. The attachment resource has a fixed schema. Regardless of where the raw media is stored, the following properties are required.
The following example illustrates the JSON construct of a document attachment.
{
"id":"image13d65101-90c4-4c2a-a423-fbf221c73233",
"contentType":"image/jpg",
"media":"www.bing.com",
"_rid":"rnYYAMVFUAUBAAAAAAAAAEC+LNM=",
"_ts":1408056025,
"_self":"dbs\/rnYYAA==\/colls\/rnYYAMVFUAU=\/docs\/rnYYAMVFUAUBAAAAAAAAAA==\/attachments\/rnYYAMVFUAUBAAAAAAAAAEC+LNM=",
"_etag":"00002a00-0000-0000-0000-53ed3ad90000"
}
Property |
Description |
id |
Required. This is a user settable property. It is the unique name that identifies the attachment, i.e. no two attachments share the same id. The id must not exceed 255 characters. |
contentType |
Required. This is a user settable property. It specifies the content type of the attachment. When submitting the attachment bits as the body, DocumentDB sets the contentType to the type set in the Content-Type header. |
Media |
Required. This is the URL link or file path where the attachment resides. |
_rid |
This is a system generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the attachment resource. |
_ts |
This is a system generated property. It specifies the last updated timestamp of the resource. The value is a timestamp. |
_self |
This is a system generated property. It is the unique addressable URI for the resource. |
_etag |
This is a system generated property that specifies the resource etag required for optimistic concurrency control. |
The following are the allowable operation on attachments.
Replace an attachment
List attachments
Delete attachments
Querying DocumentDB Resources. Note that the attachment content is not indexed or searchable; the attachment resource properties are indexed and searchable.
These operations are similar to the ones for documents. Instead of performing the operations against the docs, they are preformed against the attachments resource path under a particular document. Hence, we will skip elaborating each of the operations. Instead, in the next section, we will discuss how to create an attachment with raw media posting and with metadata-only posting.
See Also
Azure DocumentDB REST API Reference
Access Control on DocumentDB Resources
Querying DocumentDB Resources
HTTP Status Codes for DocumentDB
Operations on DocumentDB Databases
Operations on DocumentDB Users
Operations on DocumentDB Permissions
Operations on DocumentDB Documents
Operations on DocumentDB Document Collections
Operations on Stored Procedures
Operations on User Defined Functions
Operations on Triggers