Skip to content

Commit

Permalink
v7.8.0 (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
bachue authored Sep 24, 2024
1 parent 65f7cb8 commit 66642cb
Show file tree
Hide file tree
Showing 49 changed files with 3,828 additions and 1,006 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: |
set -e
cmake -S . -B build
cmake --build build
cmake --build build -j $(nproc)
- name: Unit test
working-directory: '${{ github.workspace }}/build/gtests'
run: |
Expand All @@ -38,7 +38,7 @@ jobs:
run: |
set -e
cmake -DOPENSSL_ROOT_DIR="$(brew --prefix)/opt/openssl/" -S . -B build
cmake --build build
cmake --build build -j $(nproc)
- name: Unit test
working-directory: '${{ github.workspace }}/build/gtests'
run: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## CHANGE LOG

## v7.8.0 (2024-08-27)

- 支持闲时任务和 prefop 接口
- 调整查询区域主备域名
- 支持缓存多个 `v4/query` 查询结果
- 上传重试支持切换上传域名
- 支持上传加速域名
- 增加上传进度回调支持

## v7.7.0 (2023-12-25)

- 支持归档直读存储类型
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CMAKE_POLICY(SET CMP0074 NEW)
SET(PROJECT_NAME qiniu)

# 建立项目
PROJECT(${PROJECT_NAME} VERSION 7.7.0 LANGUAGES C)
PROJECT(${PROJECT_NAME} VERSION 7.8.0 LANGUAGES C)

set(CMAKE_C_STANDARD 99)

Expand All @@ -19,16 +19,17 @@ ENDIF()

AUX_SOURCE_DIRECTORY(b64 DIR_SRCS_B64)
AUX_SOURCE_DIRECTORY(cJSON DIR_SRCS_CJSON)
AUX_SOURCE_DIRECTORY(hashmap DIR_SRCS_HASHMAP)
AUX_SOURCE_DIRECTORY(qiniu DIR_SRCS_QINIU)
MESSAGE(STATUS "Src file: ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_QINIU}")
MESSAGE(STATUS "Src file: ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_HASHMAP} ${DIR_SRCS_QINIU}")

# 编译可执行程序
# ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS})
# 如果要生成静态链接库
ADD_LIBRARY(${PROJECT_NAME}_static STATIC ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_QINIU})
ADD_LIBRARY(${PROJECT_NAME}_static STATIC ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_HASHMAP} ${DIR_SRCS_QINIU})

# 如果要生成动态链接库
ADD_LIBRARY(${PROJECT_NAME} SHARED ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_QINIU})
ADD_LIBRARY(${PROJECT_NAME} SHARED ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_HASHMAP} ${DIR_SRCS_QINIU})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
Expand Down
40 changes: 29 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ C-SDK 使用 [cURL](http://curl.haxx.se/) 进行网络相关操作。无论是

如果在项目构建过程中出现环境相关的编译错误和链接错误,请确认这些选项是否都已经正确配置,以及所依赖的库是否都已经正确的安装。

#### 通过 CMake 编译

如果想在 CMake 项目里使用 C-SDK,可以直接在 CMake 里导入 C-SDK:

```cmake
INCLUDE(FetchContent)
FetchContent_Declare(
qiniu
GIT_REPOSITORY https://github.com/qiniu/c-sdk.git
GIT_TAG v7.8.0
)
FetchContent_MakeAvailable(qiniu)
FIND_PACKAGE(CURL REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE qiniu m)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE ${CURL_LIBRARIES})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE ${OPENSSL_LIBRARIES})
```

<a name="appkey"></a>

Expand Down Expand Up @@ -169,7 +187,7 @@ typedef struct _Qiniu_Error {
typedef struct _Qiniu_RS_StatRet {
const char* hash;
const char* mimeType;
Qiniu_Int64 fsize;
Qiniu_Int64 fsize;
Qiniu_Int64 putTime;
} Qiniu_RS_StatRet;
```
Expand Down Expand Up @@ -427,7 +445,7 @@ void stat(Qiniu_Client* client, const char* bucket, const char* key)
typedef struct _Qiniu_RS_StatRet {
const char* hash;
const char* mimeType;
Qiniu_Int64 fsize;
Qiniu_Int64 fsize;
Qiniu_Int64 putTime;
} Qiniu_RS_StatRet;
```
Expand Down Expand Up @@ -456,8 +474,8 @@ void delete(Qiniu_Client* client, const char* bucket, const char* key)
复制和移动操作,需要指定源路径和目标路径。

```{c}
void copy(Qiniu_Client* client,
const char* bucketSrc, const char* keySrc,
void copy(Qiniu_Client* client,
const char* bucketSrc, const char* keySrc,
const char* bucketDest, const char* keyDest)
{
Qiniu_Error err = Qiniu_RS_Copy(client, bucketSrc, keySrc, bucketDest, keyDest);
Expand All @@ -470,8 +488,8 @@ void copy(Qiniu_Client* client,
```

```{c}
void move(Qiniu_Client* client,
const char* bucketSrc, const char* keySrc,
void move(Qiniu_Client* client,
const char* bucketSrc, const char* keySrc,
const char* bucketDest, const char* keyDest)
{
Qiniu_Error err = Qiniu_RS_Move(client, bucketSrc, keySrc, bucketDest, keyDest);
Expand All @@ -494,7 +512,7 @@ void move(Qiniu_Client* client,
调用`Qiniu_RS_BatchStat`可以批量查看多个文件的属性信息。

```{c}
void batchStat(Qiniu_Client* client,
void batchStat(Qiniu_Client* client,
Qiniu_RS_EntryPath* entries, Qiniu_ItemCount entryCount)
{
Qiniu_RS_BatchStatRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchStatRet));
Expand Down Expand Up @@ -551,7 +569,7 @@ typedef struct _Qiniu_RS_BatchStatRet {
typedef struct _Qiniu_RS_StatRet {
const char* hash;
const char* mimeType;
Qiniu_Int64 fsize;
Qiniu_Int64 fsize;
Qiniu_Int64 putTime;
} Qiniu_RS_StatRet;
```
Expand All @@ -563,7 +581,7 @@ typedef struct _Qiniu_RS_StatRet {
调用`Qiniu_RS_BatchDelete`可以批量删除多个文件。

```{c}
void batchDelete(Qiniu_Client* client,
void batchDelete(Qiniu_Client* client,
Qiniu_RS_EntryPath* entries, Qiniu_ItemCount entryCount)
{
Qiniu_RS_BatchItemRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchItemRet));
Expand Down Expand Up @@ -604,7 +622,7 @@ typedef struct _Qiniu_RS_BatchItemRet {
调用`Qiniu_RS_BatchCopy`可以批量复制多个文件。

```{c}
void batchCopy(Qiniu_Client* client,
void batchCopy(Qiniu_Client* client,
Qiniu_RS_EntryPathPair* entryPairs, Qiniu_ItemCount entryCount)
{
Qiniu_RS_BatchItemRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchItemRet));
Expand Down Expand Up @@ -644,7 +662,7 @@ typedef struct _Qiniu_RS_EntryPathPair {
批量移动和批量复制很类似,唯一的区别就是调用`Qiniu_RS_BatchMove`

```{c}
void batchMove(Qiniu_Client* client,
void batchMove(Qiniu_Client* client,
Qiniu_RS_EntryPathPair* entryPairs, Qiniu_ItemCount entryCount)
{
Qiniu_RS_BatchItemRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchItemRet));
Expand Down
47 changes: 45 additions & 2 deletions examples/fop_video_avthumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ int main(int argc, char **argv) {

char *fops[] = {avthumbMp4Fop, vframeJpgFop};

Qiniu_Error error = Qiniu_FOP_Pfop(&client, &pfopRet, bucket, key, fops, 2, pipeline, notifyURL, force);
Qiniu_FOP_PfopParams params = {
.bucket = bucket,
.key = key,
.pipeline = pipeline,
.notifyURL = notifyURL,
.fops = fops,
.fopCount = 2,
.force = force,
};
Qiniu_Error error = Qiniu_FOP_Pfop_v2(&client, &pfopRet, &params);
if (error.code != 200) {
printf("video file pfop %s:%s error.\n", bucket, key);
debug_log(&client, error);
Expand All @@ -52,7 +61,41 @@ int main(int argc, char **argv) {
printf("video file pfop %s:%s success, persistentId: %s .\n\n", bucket, key, pfopRet.persistentId);
}

Qiniu_FOP_PrefopRet prefopRet;
Qiniu_FOP_PrefopItemRet prefopItemRet[2];
Qiniu_ItemCount itemsCount;
error = Qiniu_FOP_Prefop(&client, &prefopRet, (Qiniu_FOP_PrefopItemRet *)&prefopItemRet, &itemsCount, pfopRet.persistentId, 2);
if (error.code != 200)
{
debug_log(&client, error);
}
else
{
printf("ID: %s\n", prefopRet.id);
printf("Code: %d\n", prefopRet.code);
printf("Desc: %s\n", prefopRet.desc);
printf("InputBucket: %s\n", prefopRet.inputBucket);
printf("InputKey: %s\n", prefopRet.inputKey);
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,
prefopRet.creationDate.time.minute, prefopRet.creationDate.time.second,
prefopRet.creationDate.time.offset);

for (Qiniu_ItemCount i = 0; i < itemsCount; i++)
{
printf("\tIndex: %d\n", i);
printf("\tCmd: %s\n", prefopItemRet[i].cmd);
printf("\tCode: %d\n", prefopItemRet[i].code);
printf("\tDesc: %s\n", prefopItemRet[i].desc);
printf("\tError: %s\n", prefopItemRet[i].error);
printf("\tHash: %s\n", prefopItemRet[i].hash);
printf("\tKey: %s\n", prefopItemRet[i].key);
printf("\tReturnOld: %d\n", prefopItemRet[i].returnOld);
}
}

Qiniu_Free(avthumbMp4Fop);
Qiniu_Free(vframeJpgFop);
Qiniu_Client_Cleanup(&client);
}
}
7 changes: 1 addition & 6 deletions examples/up_form_upload.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ int main(int argc, char **argv) {
putPolicy.scope = bucket;
char *uptoken = Qiniu_RS_PutPolicy_Token(&putPolicy, &mac);

//设置机房域名
//Qiniu_Use_Zone_Beimei(Qiniu_False);
//Qiniu_Use_Zone_Huabei(Qiniu_True);
Qiniu_Use_Zone_Huadong(Qiniu_False);
//Qiniu_Use_Zone_Huanan(Qiniu_True);

//put extra
//putExtra.upHost="http://nbxs-gate-up.qiniu.com";

Expand All @@ -60,6 +54,7 @@ int main(int argc, char **argv) {

//init
Qiniu_Client_InitMacAuth(&client, 1024, &mac);
Qiniu_Client_EnableAutoQuery(&client, Qiniu_True);
Qiniu_Error error = Qiniu_Io_PutFile(&client, &putRet, uptoken, key, localFile, &putExtra);
if (error.code != 200) {
printf("upload file %s:%s error.\n", bucket, key);
Expand Down
1 change: 1 addition & 0 deletions examples/up_multipart_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ int main(int argc, char **argv)
char *uptoken = Qiniu_RS_PutPolicy_Token(&putPolicy, &mac);

Qiniu_Client_InitMacAuth(&client, 1024, &mac);
Qiniu_Client_EnableAutoQuery(&client, Qiniu_True);
Qiniu_RS_Delete(&client, bucket, key); //to avoid "file exist" err

error = Qiniu_Multipart_PutFile(&client, uptoken, key, localFile, &putExtra, &putRet);
Expand Down
1 change: 1 addition & 0 deletions examples/up_resumeable_upload.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static void resumableUploadWithKey(Qiniu_Mac *mac, const char *bucket, const cha
Qiniu_Client client;
Qiniu_Global_Init(-1);
Qiniu_Client_InitNoAuth(&client, 1024);
Qiniu_Client_EnableAutoQuery(&client, Qiniu_True);

Qiniu_Error error;
Qiniu_Rio_PutRet putRet;
Expand Down
Loading

0 comments on commit 66642cb

Please sign in to comment.