uploadLayerPart method

Future<UploadLayerPartResponse> uploadLayerPart({
  1. required Uint8List layerPartBlob,
  2. required int partFirstByte,
  3. required int partLastByte,
  4. required String repositoryName,
  5. required String uploadId,
  6. String? registryId,
})

Uploads an image layer part to Amazon ECR.

When an image is pushed, each new image layer is uploaded in parts. The maximum size of each image layer part can be 20971520 bytes (or about 20MB). The UploadLayerPart API is called once per each new image layer part.

May throw ServerException. May throw InvalidParameterException. May throw InvalidLayerPartException. May throw RepositoryNotFoundException. May throw UploadNotFoundException. May throw LimitExceededException. May throw KmsException.

Parameter layerPartBlob : The base64-encoded layer part payload.

Parameter partFirstByte : The position of the first byte of the layer part witin the overall image layer.

Parameter partLastByte : The position of the last byte of the layer part within the overall image layer.

Parameter repositoryName : The name of the repository to which you are uploading layer parts.

Parameter uploadId : The upload ID from a previous InitiateLayerUpload operation to associate with the layer part upload.

Parameter registryId : The AWS account ID associated with the registry to which you are uploading layer parts. If you do not specify a registry, the default registry is assumed.

Implementation

Future<UploadLayerPartResponse> uploadLayerPart({
  required Uint8List layerPartBlob,
  required int partFirstByte,
  required int partLastByte,
  required String repositoryName,
  required String uploadId,
  String? registryId,
}) async {
  ArgumentError.checkNotNull(layerPartBlob, 'layerPartBlob');
  ArgumentError.checkNotNull(partFirstByte, 'partFirstByte');
  _s.validateNumRange(
    'partFirstByte',
    partFirstByte,
    0,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(partLastByte, 'partLastByte');
  _s.validateNumRange(
    'partLastByte',
    partLastByte,
    0,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    2,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(uploadId, 'uploadId');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonEC2ContainerRegistry_V20150921.UploadLayerPart'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'layerPartBlob': base64Encode(layerPartBlob),
      'partFirstByte': partFirstByte,
      'partLastByte': partLastByte,
      'repositoryName': repositoryName,
      'uploadId': uploadId,
      if (registryId != null) 'registryId': registryId,
    },
  );

  return UploadLayerPartResponse.fromJson(jsonResponse.body);
}