mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-19 01:58:14 +08:00
feat(work): 新增微盘文件分块上传相关接口
This commit is contained in:
@@ -254,6 +254,66 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinWedriveFileDownloadResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/wedrive/file_upload_init 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/98004 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinWedriveFileUploadInitializeResponse> ExecuteCgibinWedriveFileUploadInitializeAsync(this WechatWorkClient client, Models.CgibinWedriveFileUploadInitializeRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cgi-bin", "wedrive", "file_upload_init")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinWedriveFileUploadInitializeResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/wedrive/file_upload_part 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/98004 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinWedriveFileUploadPartResponse> ExecuteCgibinWedriveFileUploadPartAsync(this WechatWorkClient client, Models.CgibinWedriveFileUploadPartRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cgi-bin", "wedrive", "file_upload_part")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinWedriveFileUploadPartResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/wedrive/file_upload_finish 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/98004 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinWedriveFileUploadFinishResponse> ExecuteCgibinWedriveFileUploadFinishAsync(this WechatWorkClient client, Models.CgibinWedriveFileUploadFinishRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cgi-bin", "wedrive", "file_upload_finish")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinWedriveFileUploadFinishResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/wedrive/file_create 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/97882 </para>
|
||||
|
@@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/wedrive/file_upload_finish 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinWedriveFileUploadFinishRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置上传凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("upload_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("upload_key")]
|
||||
public string UploadKey { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/wedrive/file_upload_finish 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinWedriveFileUploadFinishResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置文件 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fileid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("fileid")]
|
||||
public string FileId { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/wedrive/file_upload_init 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinWedriveFileUploadInitializeRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置 JSAPI 返回的 SelectedTicket。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("selected_ticket")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("selected_ticket")]
|
||||
public string? SelectedTicket { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置空间 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("spaceid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("spaceid")]
|
||||
public string? SpaceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置上级文件 ID 或空间 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fatherid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("fatherid")]
|
||||
public string? ParentFileOrSpaceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文件名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("file_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("file_name")]
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文件大小(单位:字节)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("size")]
|
||||
public int FileSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文件分块 SHA 哈希值列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("block_sha")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("block_sha")]
|
||||
public IList<string> BlockSHAList { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否跳过推送。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("skip_push_card")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("skip_push_card")]
|
||||
public bool? IsSkipPushCard { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/wedrive/file_upload_init 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinWedriveFileUploadInitializeResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置是否命中秒传。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("hit_exist")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("hit_exist")]
|
||||
public bool IsHitExist { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置上传凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("upload_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("upload_key")]
|
||||
public string? UploadKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文件 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("fileid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("fileid")]
|
||||
public string? FileId { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/wedrive/file_upload_part 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinWedriveFileUploadPartRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置上传凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("upload_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("upload_key")]
|
||||
public string UploadKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文件分块号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("index")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("index")]
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置经过 Base64 编码的文件分块内容。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("file_base64_content")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("file_base64_content")]
|
||||
public string EncodingBlockContent { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/wedrive/file_upload_part 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinWedriveFileUploadPartResponse : WechatWorkResponse
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"upload_key": "UPLOAD_KEY"
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"fileid": "FILEID"
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"spaceid": "SPACEID",
|
||||
"fatherid": "FATHERID",
|
||||
"selected_ticket": "SELECTED_TICKET",
|
||||
"file_name": "FILE_NAME",
|
||||
"size": 123,
|
||||
"block_sha": ["STATE1", "STATE2"],
|
||||
"skip_push_card": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"hit_exist": false,
|
||||
"upload_key": "UPLOAD_KEY",
|
||||
"fileid": "FILEID"
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"upload_key": "UPLOAD_KEY",
|
||||
"index": 1,
|
||||
"file_base64_content": "FILE_BASE64_CONTENT"
|
||||
}
|
Reference in New Issue
Block a user