Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

This section provides general information about SCSP WRITE that applies to both named and unnamed objects.

WRITE is a request to the storage cluster to create a new object. The WRITE request is formatted as an HTTP request using the POST method.

SCSP Method

HTTP Method

RFC 7231 Section

SCSP WRITE

POST

4.3.3

Write for contexts

The Swarm setting scsp.requireExplicitContextCreate protects content-bearing objects from being created erroneously as contexts (buckets or domains). With this setting enabled, Swarm does not create a context object unless it includes the required header: Content-type: application/castorcontext. (v9.1)

S3 compatibility

The Swarm setting scsp.autoContentMD5Computation improves S3 compatibility by automating Content-MD5 hashing. the gencontentmd5 query argument or the deprecated Expect: Content-MD5 header does not need to be included on writes (although a separate Content-MD5 header may want to be supplied for content integrity checking). This setting is ignored wherever it is invalid, such as on a multipart initiate/complete or an EC APPEND. (v9.1)

WRITE for named objects

The existing object is overwritten with a new version if performing a WRITE of a named object that already exists.

WRITE that overwrites object
POST /bucket/photo.jpg HTTP/1.1
  Host: cluster.example.com
  User-Agent: Swarm Client/0.1
  Content-Length: 43402
  Expect: 100-continue
  Content-Type: image/jpeg 
  Content-Language: en/us, x-pig-latin 
  Content-Version: 42
  CRLF
  [ content ]

Include the If-None-Match: * request header to prevent overwriting an existing object.

  • Swarm WRITEs the named object if the named object does not exist.

  • Swarm responds with an HTTP 412 Precondition Fail error if the named object exists.

WRITE that prevents overwriting
POST /bucket/photo.jpg HTTP/1.1
  If-None-Match: *
  Host: cluster.example.com
  User-Agent: Swarm Client/0.1
  Content-Length: 43402
  Expect: 100-continue
  Content-Type: image/jpeg
  Content-Language: en/us, x-pig-latin
  Content-Version: 42 
  CRLF 
  [ content ]

Using PUT Create for named objects

Add the scsp.allowPutCreate=True to the configuration parameters to configure Swarm to allow using the HTTP PUT operation to create new named objects. The putcreate query argument can also enable it.

Exception

Although domains and buckets are named, Swarm processes all PUT requests on these objects as updates, regardless of the setting.

  • Swarm fails the request with a 400 Bad Request error if the putcreate=yes query argument is used on a domain or bucket.

  • Swarm silently ignores it and processes the request as an ordinary PUT if the scsp.allowPutCreate parameter is enabled.

Preventing overwriting: If-None-Match

In contrast to an unnamed object, the existing object is overwritten with a new version if performing a WRITE of a named object that already exists. Include the If-None-Match: * request header to prevent overwriting an existing object.

  • Swarm WRITEs the named object if the named object does not exist.

  • Swarm responds with an HTTP 412 Precondition Fail error if the named object exists.

Note

Swarm returns an HTTP 412 error on SCSP WRITE of named objects if the domain or bucket does not exist or cannot be loaded.

Note

If‑None‑Match:* can erroneously report that an object exists during the time window after it is flagged for deletion by policy but before it is removed from disk. This window is determined by the HP cycle time.

WRITE for unnamed objects

Swarm makes no assumptions about User-Agent (except it is an HTTP/1.1 client). The Host header must conform to the requirements of Section 14.23 of the HTTP/1.1 spec.

WRITE unnamed to host domain
POST / HTTP/1.1 
  Host: cluster.example.com 
  User-Agent:Swarm Client/0.1 
  Content-Length: 43402 
  Expect: 100-continue
  Content-Type: image/jpeg
  Content-Language: en/us, x-pig-latin
  Content-Version: 42 
  CRLF 
  [ content ]

A new object is created and a new UUID is returned if performing a WRITE of an unnamed object. A new object is created and a new alias UUID is returned if performing a WRITE of an alias object.

See WRITE for Unnamed Objects.

WRITE for alias objects

Add alias=yes to create alias objects:

WRITE for alias object
POST /?alias HTTP/1.1
  Host: cluster.example.com
  User-Agent: Swarm Client/0.1

WRITE for erasure-coded objects

A new object written to the storage cluster is erasure-coded if it meets the EC criteria language.

See Working with Large Objects.

Note

Swarm returns a HTTP 503 Service Unavailable error if performing a WRITE of an object of more than 4 TB in size.

WRITE for large files (Expect: 100-continue)

The Expect: 100-continue header tells the server the client waits after sending the header lines and before sending the content in the message body. The Swarm server can respond with a redirect or an error response.

  • The server returns an HTTP 100 Continue response, telling the client to transmit the entity body if the server is ready to store the contents. The client needs to wait for a 100 Continue response from the server before proceeding to send the data.

  • The server sends an HTTP 413 Request entity too large error response and closes the connection if the server is not ready.

Swarm allows the client to omit the Expect: 100-continue header, sending all content at once. The server reads and discards all data if it must respond with a redirect or error. Swarm logs a warning for WRITE messages that include more than 65536 bytes:

Error if Expect header is missing
Please use Expect: 100-continue for large amounts of data.

The cluster returns an HTTP 507 Insufficient Storage error if any node in the cluster does not have enough space to write the object.

  • No labels