diff --git a/CHANGELOG.md b/CHANGELOG.md index dec93d7..3bab8cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## CHANGE LOG +## v7.9.0 (2024-10-21) + +- 支持工作流模版 + ## v7.8.0 (2024-08-27) - 支持闲时任务和 prefop 接口 diff --git a/examples/fop_video_avthumb.c b/examples/fop_video_avthumb.c index ed3da2b..337ffac 100644 --- a/examples/fop_video_avthumb.c +++ b/examples/fop_video_avthumb.c @@ -76,6 +76,7 @@ int main(int argc, char **argv) { printf("Desc: %s\n", prefopRet.desc); printf("InputBucket: %s\n", prefopRet.inputBucket); printf("InputKey: %s\n", prefopRet.inputKey); + printf("TaskFrom: %s\n", prefopRet.taskFrom); printf("Type: %d\n", prefopRet.type); printf("CreationDate: %d-%d-%d %d:%d:%d +%d\n", prefopRet.creationDate.date.year, prefopRet.creationDate.date.month, prefopRet.creationDate.date.day, prefopRet.creationDate.time.hour, diff --git a/qiniu/fop.c b/qiniu/fop.c index dc38744..5bf81d3 100644 --- a/qiniu/fop.c +++ b/qiniu/fop.c @@ -38,18 +38,20 @@ Qiniu_Error Qiniu_FOP_Pfop_v2(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, Qiniu_ char *typeStr = NULL; char *url = NULL; char *body = NULL; - Qiniu_Bool escapeBucketOk; - Qiniu_Bool escapeKeyOk; - Qiniu_Bool escapeFopsOk; - Qiniu_Bool escapePipelineOk; - Qiniu_Bool escapeNotifyURLOk; + Qiniu_Bool escapeBucketOk = Qiniu_False; + Qiniu_Bool escapeKeyOk = Qiniu_False; + Qiniu_Bool escapeFopsOk = Qiniu_False; + Qiniu_Bool escapePipelineOk = Qiniu_False; + Qiniu_Bool escapeNotifyURLOk = Qiniu_False; // Add encoded bucket encodedBucket = Qiniu_QueryEscape(params->bucket, &escapeBucketOk); encodedKey = Qiniu_QueryEscape(params->key, &escapeKeyOk); - fopsStr = Qiniu_String_Join(";", params->fops, params->fopCount); - encodedFops = Qiniu_QueryEscape(fopsStr, &escapeFopsOk); - Qiniu_Free(fopsStr); + if (params->fopCount > 0 || params->fops){ + fopsStr = Qiniu_String_Join(";", params->fops, params->fopCount); + encodedFops = Qiniu_QueryEscape(fopsStr, &escapeFopsOk); + Qiniu_Free(fopsStr); + } if (params->pipeline) { @@ -84,9 +86,19 @@ Qiniu_Error Qiniu_FOP_Pfop_v2(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, Qiniu_ typeStr = "0"; } - body = Qiniu_String_Concat("bucket=", encodedBucket, "&key=", encodedKey, "&fops=", encodedFops, - "&pipeline=", encodedPipeline, "¬ifyURL=", encodedNotifyURL, "&force=", forceStr, - "&type=", typeStr, NULL); + if (escapeFopsOk) + { + body = Qiniu_String_Concat("bucket=", encodedBucket, "&key=", encodedKey, "&fops=", encodedFops, + "&pipeline=", encodedPipeline, "¬ifyURL=", encodedNotifyURL, "&force=", forceStr, + "&type=", typeStr, NULL); + } + else + { + body = Qiniu_String_Concat("bucket=", encodedBucket, "&key=", encodedKey, "&workflowTemplateID=", params->workflowTemplateID, + "&pipeline=", encodedPipeline, "¬ifyURL=", encodedNotifyURL, "&force=", forceStr, + "&type=", typeStr, NULL); + } + if (escapeBucketOk) { Qiniu_Free(encodedBucket); @@ -195,6 +207,7 @@ Qiniu_Error Qiniu_FOP_Prefop(Qiniu_Client *self, Qiniu_FOP_PrefopRet *ret, Qiniu ret->desc = Qiniu_Json_GetString(root, "desc", NULL); ret->inputBucket = Qiniu_Json_GetString(root, "inputBucket", NULL); ret->inputKey = Qiniu_Json_GetString(root, "inputBucket", NULL); + ret->taskFrom = Qiniu_Json_GetString(root, "taskFrom", NULL); ret->type = Qiniu_Json_GetInt(root, "type", 0); creationDateStr = (char *)Qiniu_Json_GetString(root, "creationDate", NULL); if (creationDateStr != NULL) diff --git a/qiniu/fop.h b/qiniu/fop.h index 27d4554..47d3eb5 100644 --- a/qiniu/fop.h +++ b/qiniu/fop.h @@ -33,6 +33,7 @@ typedef struct _Qiniu_FOP_PfopParams const char *key; const char *pipeline; const char *notifyURL; + const char *workflowTemplateID; char **fops; int fopCount; int force; @@ -57,6 +58,7 @@ typedef struct _Qiniu_FOP_PrefopRet const char *desc; const char *inputBucket; const char *inputKey; + const char *taskFrom; int code; int type; Qiniu_DateTime creationDate; diff --git a/qiniu/rs.c b/qiniu/rs.c index 1b0c4e9..deb8166 100644 --- a/qiniu/rs.c +++ b/qiniu/rs.c @@ -80,6 +80,10 @@ char *Qiniu_RS_PutPolicy_Token(Qiniu_RS_PutPolicy *auth, Qiniu_Mac *mac) { cJSON_AddStringToObject(root, "persistentPipeline", auth->persistentPipeline); } + if (auth->persistentWorkflowTemplateID) + { + cJSON_AddStringToObject(root, "persistentWorkflowTemplateID", auth->persistentWorkflowTemplateID); + } if (auth->mimeLimit) { cJSON_AddStringToObject(root, "mimeLimit", auth->mimeLimit); diff --git a/qiniu/rs.h b/qiniu/rs.h index ee0da67..51e1a83 100644 --- a/qiniu/rs.h +++ b/qiniu/rs.h @@ -49,6 +49,7 @@ typedef struct _Qiniu_RS_PutPolicy { const char *persistentOps; const char *persistentNotifyUrl; const char *persistentPipeline; + const char *persistentWorkflowTemplateID; const char *mimeLimit; Qiniu_Uint64 fsizeLimit; Qiniu_Uint64 fsizeMin;