putBlob method

Future<void> putBlob(
  1. String path, {
  2. String? body,
  3. Uint8List? bodyBytes,
  4. required String contentType,
  5. BlobType type = BlobType.blockBlob,
})

Put Blob.

body and bodyBytes are mutually exclusive and mandatory.

Implementation

Future<void> putBlob(String path, {String? body, Uint8List? bodyBytes, required String contentType, BlobType type = BlobType.blockBlob}) async {
  assert((bodyBytes == null) ^ (body == null));
  var request = http.Request('PUT', uri(path: path));
  if (type == BlobType.blockBlob) {
    if (bodyBytes != null) {
      request.bodyBytes = bodyBytes;
    } else if (body != null) {
      request.body = body;
    }
  } else {
    request.body = '';
  }

  request.headers['x-ms-blob-type'] = type.toString() == 'BlobType.AppendBlob' ? 'AppendBlob' : 'BlockBlob';
  request.headers['Content-Type'] = contentType;

  _sign(request);
  // request.headers['acceptHeader'] = contentType;
  // request.headers['accept'] = contentType;
  // request.headers['contentTypeHeader'] = contentType;
  // request.headers['authorizationHeader'] = "";
  var res = request.send();
  // var message = await res. bytesToString();
  // throw AzureStorageException(message, res.statusCode, res.headers);
}