Method: Azure::Storage::Blob#create_append_blob

Defined in:
lib/azure/storage/blob/append.rb

#create_append_blob(container, blob, options = {}) ⇒ Object

Public: Creates a new append blob. Note that calling create_append_blob to create an append blob only initializes the blob. To add content to an append blob, call append_blob_blocks method.

Attributes

  • container - String. The container name.

  • blob - String. The blob name.

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :content_type - String. Content type for the blob. Will be saved with blob.

  • :content_encoding - String. Content encoding for the blob. Will be saved with blob.

  • :content_language - String. Content language for the blob. Will be saved with blob.

  • :content_md5 - String. Content MD5 for the blob. Will be saved with blob.

  • :cache_control - String. Cache control for the blob. Will be saved with blob.

  • :content_disposition - String. Conveys additional information about how to process the response payload,

    and also can be used to attach additional metadata
    
  • :metadata - Hash. Custom metadata values to store with the blob.

  • :timeout - Integer. A timeout in seconds.

  • :request_id - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded

    in the analytics logs when storage analytics logging is enabled.
    
  • :if_modified_since - String. A DateTime value. Specify this conditional header to create a new blob

    only if the blob has been modified since the specified date/time. If the blob has not been modified,
    the Blob service returns status code 412 (Precondition Failed).
    
  • :if_unmodified_since - String. A DateTime value. Specify this conditional header to create a new blob

    only if the blob has not been modified since the specified date/time. If the blob has been modified,
    the Blob service returns status code 412 (Precondition Failed).
    
  • :if_match - String. An ETag value. Specify an ETag value for this conditional header to create a new blob

    only if the blob's ETag value matches the value specified. If the values do not match,
    the Blob service returns status code 412 (Precondition Failed).
    
  • :if_none_match - String. An ETag value. Specify an ETag value for this conditional header to create a new blob

    only if the blob's ETag value does not match the value specified. If the values are identical,
    the Blob service returns status code 412 (Precondition Failed).
    
  • :lease_id - String. Required if the blob has an active lease. To perform this operation on a blob with an active lease,

    specify the valid lease ID for this header.
    

See msdn.microsoft.com/en-us/library/azure/dd179451.aspx

Returns a Blob



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/azure/storage/blob/append.rb', line 70

def create_append_blob(container, blob, options = {})
  query = {}
  StorageService.with_query query, "timeout", options[:timeout] if options[:timeout]

  uri = blob_uri(container, blob, query)

  headers = {}

  # set x-ms-blob-type to AppendBlob
  StorageService.with_header headers, "x-ms-blob-type", "AppendBlob"

  # ensure content-length is 0
  StorageService.with_header headers, "Content-Length", 0

  # set the rest of the optional headers
  StorageService.with_header headers, "x-ms-blob-content-type", options[:content_type]
  StorageService.with_header headers, "x-ms-blob-content-encoding", options[:content_encoding]
  StorageService.with_header headers, "x-ms-blob-content-language", options[:content_language]
  StorageService.with_header headers, "x-ms-blob-content-md5", options[:content_md5]
  StorageService.with_header headers, "x-ms-blob-cache-control", options[:cache_control]
  StorageService.with_header headers, "x-ms-blob-content-disposition", options[:content_disposition]

  StorageService. options[:metadata], headers
  add_blob_conditional_headers options, headers
  headers["x-ms-lease-id"] = options[:lease_id] if options[:lease_id]
  headers["x-ms-blob-content-type"] = Default::CONTENT_TYPE_VALUE unless headers["x-ms-blob-content-type"]

  # call PutBlob with empty body
  response = call(:put, uri, nil, headers, options)

  result = Serialization.blob_from_headers(response.headers)
  result.name = blob
  result. = options[:metadata] if options[:metadata]

  result
end