Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

Table of Contents

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 a simple HTTP request using the POST method.

SCSP Method

HTTP Method

RFC 7231 Section

SCSP WRITE

POST

4.3.3


Info
title

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 will not create a context object unless it includes the required header: Content-type: application/castorcontext. (v9.1)


Info
title

S3 compatibility

The Swarm setting scsp.autoContentMD5Computation improves S3 compatibility by automating Content-MD5 hashing, which means that you do not need to include the gencontentmd5 query argument or the deprecated Expect: Content-MD5 header on writes (although you may want to supply your own Content-MD5 header 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

If you WRITE a named object that already exists, the existing object is overwritten with a new version.

WRITE that overwrites object
Code Block
title
languagexmlWRITE 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 ]

To prevent overwriting an existing object, include the If-None-Match: * request header.

  • If the named object does not exist, Swarm WRITEs the named object.

  • If the named object exists, Swarm responds with a 412 Precondition Fail error.

WRITE that prevents overwriting
Code Block
title
languagexmlWRITE 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 ]

...

If you want to configure Swarm to allow you to use the HTTP PUT operation to create new named objects, add the scsp.allowPutCreate=True to your configuration parameters. You can also enable it using the putcreate query argument.

Info
title

Exception

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

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

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

Preventing overwriting: If-None-Match

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

  • If the named object does not exist, Swarm WRITEs the named object.

  • If the named object exists, Swarm responds with a 412 Precondition Fail error.


Info

...

Note

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


title
Info

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 that 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
Code Block
languagexml
titleWRITE 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 ]

If you WRITE an unnamed object, a new object is created and a new UUID is returned. If you WRITE an alias object, a new object is created and a new alias UUID is returned.

See WRITE for Unnamed Objects.

WRITE for alias objects

To create alias objects, add alias=yes:

WRITE for alias object
Code Block
title
languagexmlWRITE 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.

Info
title

Note

If you WRITE an object of more than 4 TB in size, Swarm returns a 503 Service Unavailable error.

WRITE for large files (Expect: 100-continue)

The Expect: 100-continue header tells the server that the client will wait 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.

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

  • If the server is not ready, it sends a 413 Request entity too large error response and closes the connection.

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

...

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

If any node in the cluster does not have enough space to write the object, the cluster returns a 507 Insufficient Storage error.

Child pages (Children Display)