Skip to content

CDNetworks-Object-Storage/wcs-c-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wcs-c-sdk

C SDK for wcs

1 Brief Introduction

The usage of this SDK is compliant with C89 standard.

Includes:

  • Pubilc Part: src/wcs/base.c, src/wcs/conf.c, src/wcs/http.c, src/base/log.c
  • Upload small file from client: src/wcs/base_io.c io.c
  • Multipart upload/breakpoint upload from client: src/base/threadpoo.c, src/base/inifile.c, src/base/patchfileops.c, src/wcs/ multipart_io.c
  • Media processing: src/wcs/fop.c

2 Install

The C-SDK uses cURL, OpenSSL, and it requires the dependency libraries to be installed.

GCC compile options: -lcurl –lssl -lcrypto -lm

If an error such as a connection occurs during project compilation, you need to first check if the dependency libraries and compilation options are correct.

Note: Windows environments can be installed using the libraries provided in the Windows directory.

3 Related Information

The calling interface uses ACCESS_KEY, SECRET_KEY, upload domain and management domain, which can be obtained from SI portal.

4 Log

The problems can be analyzed with the Log, which is divided into six levels. You can choose whether to write to the file or not (for the purpose of performance, it is not recommended to configure writing to the file).

> Configuration (LogConfig.ini): [SDKLogConfig]
LOG_LEVEL=5 //0 means print most lines, 5 is recommended
WRITE_FILE=0 //0 means not write to the file	
LOG_FILE=./SDKTest.log //write the file name of log 

Notes: If there is no LogConfig.ini, the default setting is LOG_LEVEL=5 and NOT write to the file.

> void wcs_Log_Init(char *logConfigFile, FILE *file); // logConfigFile is the path and name of the configuration file
void wcs_close_Logfile(FILE *file);

5 Interface Calling

> Initialize and de-initialize:
wcs_Global_Init (0);
wcs_MacAuth_Init ();
wcs_Client_InitNoAuth (&client, 8192);
……
wcs_Client_Cleanup (&client);	
wcs_Global_Cleanup ();

The interface is called in the ellipsis section. This initial call should be made only one time in the main thread, and it is best not to make multiple calls in multiple threads, otherwise unexpected errors can occur.

6 API Description

(Note: The ret para input by each interface should be initialized)

Interface Function Name Notes
Generate Upload Credential char *wcs_RS_PutPolicy_Token (wcs_RS_PutPolicy * auth, wcs_Mac * mac)
Normal Upload wcs_Error wcs_Io_PutFile (wcs_Client * self, wcs_Io_PutRet * ret, const char *uptoken, const char *key, const char *localFile, wcs_Io_PutExtra * extra)
Multipart Upload wcs_Error wcs_Multipart_PutFile (wcs_Client * self, wcs_Multipart_PutRet * ret, const char *uptoken , const char *key, const char *localFile, wcs_Multipart_PutExtra * extra) This interface do multiupload through multi-thread, and the max thread can be modified: wcs_Multipart_MaxThreadNum
Breakpoint Upload wcs_Error wcs_Multipart_UploadCheck(const char *configFile, wcs_Client * self, wcs_Multipart_PutRet * ret)
Delete File wcs_Error wcs_RS_Delete (wcs_Client * self, const char *tableName, const char *key, const char *mgrHost)
Get File Information wcs_Error wcs_RS_Stat (wcs_Client * self, wcs_RS_StatRet * ret, const char *tableName, const char *key, const char *mgrHost)
List Resource wcs_Error wcs_RS_List (wcs_Client * self, wcs_RS_ListRet * ret, const char *bucketName, wcs_Common_Param * param, const char *mgrHost)
Move Resource wcs_Error wcs_RS_Move (wcs_Client * self, const char *tableNameSrc, const char *keySrc, const char *tableNameDest, const char *keyDest, const char *mgrHost)
Update Mirroring Resource wcs_Error wcs_RS_UpdateMirror(wcs_Client * self, wcs_RS_StatRet * ret, const char *bucketName, const char **fileNameList, unsigned int fileNum, const char *mgrHost)
Audio/Video Processing wcs_Error wcs_Fops_Media (wcs_Client * self, wcs_FOPS_Response * ret, wcs_FOPS_MediaParam *param, const char *mgrHost)
Get Resource wcs_Error wcs_Fops_Fetch(wcs_Client * self, wcs_FOPS_Response * ret, wcs_FOPS_FetchParam *ops[], unsigned int opsNum, const char *mgrHost )
Copy Resource wcs_Error wcs_RS_Copy (wcs_Client * self, const char *tableNameSrc, const char *keySrc, const char *tableNameDest, const char *keyDest, const char *mgrHost)
Base64 Coding wcs_Error wcs_Encode_Base64(int argc, char **argv)

7 Example

  • demo

  • fops for video

YXZ0aHVtYi9mbHYvdmIvNjRrfHNhdmVzL2FHRnNaWGwwWlhOME9uUmxjM1JXYVdSbGJ3PT07YXZ0aHVtYi9tNGEvdmIvMTI4S3xzYXZlcy9hR0ZzWlhsMFpYTjBPblJsYzNSQmRXUnBidz09
  • fops for fetchURL
fetchURL/aHR0cDovL2ltYWdlcy53Lndjc2FwaS5iaXoubWF0b2Nsb3VkLmNvbS8xLnBuZw==/bucket/aGFsZXl0ZXN0/key/dGVzdE1lZGlh/prefix/bWVkaWE=/md5/aa36f4e18a13762d77cce9e749976b3c/decompression/zip 
multiple fops supported, separated by (;)

About

wcs-c-sdk

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •