putObjectCopy method

Future<COSCopyObjectResult> putObjectCopy({
  1. String? bucketName,
  2. String? region,
  3. required String objectKey,
  4. required String xCOSCopySource,
  5. required String contentType,
  6. COSACLHeader? aclHeader,
  7. Map<String, String> headers = const <String, String>{},
})
inherited

PUT Object - Copy 接口请求创建一个已存在 COS 的对象的副本,即将一个对象从源路径(对象键)复制到目标路径(对象键) bucketName region objectKey xCOSCopySource contentType headers

Implementation

Future<COSCopyObjectResult> putObjectCopy({
  String? bucketName,
  String? region,
  required String objectKey,
  required String xCOSCopySource,
  required String contentType,
  COSACLHeader? aclHeader,
  Map<String, String> headers = const <String, String>{},
}) async {
  final Map<String, String> newHeaders = Map.of(headers);
  if (aclHeader != null) {
    newHeaders.addAll(aclHeader.toMap());
  }
  newHeaders['x-cos-copy-source'] = xCOSCopySource;
  newHeaders['Content-Type'] = contentType;
  final Response response = await client.put(
    '${getBaseApiUrl(bucketName, region)}/$objectKey',
    headers: newHeaders,
  );
  return toXml<COSCopyObjectResult>(response)(COSCopyObjectResult.fromXml);
}