Files
g.hnyhua.cn/COSXML/Model/Object/AbortMultipartUploadRequest.cs
2026-02-07 15:48:27 +08:00

69 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Text;
using COSXML.Common;
using COSXML.CosException;
namespace COSXML.Model.Object
{
/// <summary>
/// 舍弃一个分块上传并删除已上传的块
/// <see cref="https://cloud.tencent.com/document/product/436/7740"/>
/// </summary>
public sealed class AbortMultipartUploadRequest : ObjectRequest
{
/// <summary>
/// 分片块的UploadId,使用 Initiate Multipart Upload 接口初始化分片上传时会得到一个 uploadId该 ID 不但唯一标识这一分块数据,也标识了这分块数据在整个文件内的相对位置
/// </summary>
private string uploadId;
public AbortMultipartUploadRequest(string bucket, string key, string uploadId)
: base(bucket, key)
{
this.uploadId = uploadId;
this.method = CosRequestMethod.DELETE;
}
/// <summary>
/// 分片块上传的UploadId
/// </summary>
/// <param name="uploadId"></param>
public void SetUploadId(string uploadId)
{
this.uploadId = uploadId;
}
/// <summary>
/// 分片块上传的UploadId
/// </summary>
/// <returns>uploadId</returns>
public string GetUploadId()
{
return uploadId;
}
public override void CheckParameters()
{
if (requestUrlWithSign != null) return;
base.CheckParameters();
if (uploadId == null)
{
throw new CosClientException((int)CosClientError.INVALID_ARGUMENT, "uploadId is null");
}
}
protected override void InternalUpdateQueryParameters()
{
try
{
this.queryParameters.Add("uploadId", uploadId);
}
catch (ArgumentException)
{
this.queryParameters["uploadId"] = uploadId;
}
}
}
}