PutObjectInline (SOAP API)
Note
SOAP support over HTTP is deprecated, but it is still available over HTTPS. New Amazon S3 features will not be supported for SOAP. We recommend that you use either the REST API or the Amazon SDKs.
The PutObjectInline
operation adds an object to a bucket. The data for the object is provided in the body of the SOAP message.
If an object already exists in a bucket, the new object will overwrite it because Amazon S3 stores the last write request. However, Amazon S3 is a distributed system. If Amazon S3 receives multiple write requests for the same object nearly simultaneously, all of the objects might be stored, even though only one wins in the end. Amazon S3 does not provide object locking; if you need this, make sure to build it into your application layer.
To ensure an object is not corrupted over the network, you can calculate the MD5 of an object, PUT it to Amazon S3, and compare the returned Etag to the calculated MD5 value.
PutObjectInline is not suitable for use with large objects. The system
limits this operation to working with objects 1MB or smaller. PutObjectInline
will fail with the InlineDataTooLargeError
status code
if the Data parameter encodes an object larger than 1MB. To upload large
objects, consider using the non-inline PutObject API, or the REST API instead.
Example
This example writes some text and metadata into the "Nelson" object in the "quotes" bucket,
give a user (usually the owner) FULL_CONTROL
access to the object, and make the
object readable by anonymous parties.
Sample Request
<PutObjectInline xmlns="http://doc.s3.amazonaws.com/2006-03-01"> <Bucket>quotes</Bucket> <Key>Nelson</Key> <Metadata> <Name>Content-Type</Name> <Value>text/plain</Value> </Metadata> <Metadata> <Name>family</Name> <Value>Muntz</Value> </Metadata> <Data>aGEtaGE=</Data> <ContentLength>5</ContentLength> <AccessControlList> <Grant> <Grantee xsi:type="CanonicalUser"> <ID>a9a7b886d6fde241bf9b1c61be666e9</ID> <DisplayName>chriscustomer</DisplayName> </Grantee> <Permission>FULL_CONTROL</Permission> </Grant> <Grant> <Grantee xsi:type="Group"> <URI>http://acs.amazonaws.com/groups/global/AllUsers</URI> </Grantee> <Permission>READ</Permission> </Grant> </AccessControlList> <AWSAccessKeyId>AKIAIOSFODNN7EXAMPLE</AWSAccessKeyId> <Timestamp>2006-03-01T12:00:00.183Z</Timestamp> <Signature>Iuyz3d3P0aTou39dzbqaEXAMPLE=</Signature> </PutObjectInline>
Sample Response
<PutObjectInlineResponse xmlns="http://s3.amazonaws.com/doc/2006-03-01"> <PutObjectInlineResponse> <ETag>"828ef3fdfa96f00ad9f27c383fc9ac7f"</ETag> <LastModified>2006-01-01T12:00:00.000Z</lastModified> </PutObjectInlineResponse> </PutObjectInlineResponse>
Elements
-
Bucket:
The bucket in which to add the object. -
Key:
The key to assign to the object.Important
Replacement must be made for object keys containing special characters (such as carriage returns) when using XML requests. For more information, see XML related object key constraints.
-
Metadata:
You can provide name-value metadata pairs in the metadata element. These will be stored with the object. -
Data:
The base 64 encoded form of the data. -
ContentLength:
The length of the data in bytes. -
AccessControlList:
An Access Control List for the resource. This element is optional. If omitted, the requester is givenFULL_CONTROL
access to the object. If the object already exists, the preexisting access control policy is replaced.
Responses
ETag:
The entity tag is an MD5 hash of the object that you can use to do conditional fetches of the object usingGetObjectExtended
. The ETag only reflects changes to the contents of an object, not its metadata.-
LastModified:
The Amazon S3 timestamp for the saved object.
Access Control
You must have WRITE
access to the bucket in order to put objects into the bucket.