|
@@ -2,31 +2,20 @@
|
|
|
#define _H_UFILESDK_C_UCLOUD_API_
|
|
|
|
|
|
#include <stdio.h>
|
|
|
-#include <string>
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
-//*******************************common data********************************
|
|
|
-struct __declspec(dllexport) ufile_error {
|
|
|
- std::string errorCode;
|
|
|
- std::string errorMessage;
|
|
|
- std::string resourceAddr;
|
|
|
- std::string cosRequestId;
|
|
|
- std::string cosTraceId;
|
|
|
- bool bIsSuccess;
|
|
|
- int httpStatus;
|
|
|
- ufile_error()
|
|
|
- {
|
|
|
- errorCode = "";
|
|
|
- errorMessage = "";
|
|
|
- resourceAddr = "";
|
|
|
- cosRequestId = "";
|
|
|
- cosTraceId = "";
|
|
|
- bIsSuccess = false;
|
|
|
- httpStatus = 0;
|
|
|
- }
|
|
|
-};
|
|
|
+ //*******************************common data********************************
|
|
|
+ struct __declspec(dllexport) ufile_error {
|
|
|
+ bool bIsSuccess;
|
|
|
+ int httpStatus;
|
|
|
+ char errorCode[32];
|
|
|
+ char resourceAddr[64];
|
|
|
+ char cosRequestId[64];
|
|
|
+ char errorMessage[128];
|
|
|
+ char cosTraceId[256];
|
|
|
+ };
|
|
|
|
|
|
#define UFILE_OK 0
|
|
|
#define UFILE_ERROR_CODE -1
|
|
@@ -41,114 +30,114 @@ struct __declspec(dllexport) ufile_error {
|
|
|
#define CURL_INIT_ERROR_MSG "init curl failed."
|
|
|
|
|
|
#define UFILE_HAS_ERROR(CODE) ((CODE) != 0 && (CODE)/100 != 2 )
|
|
|
-//****************************************************************** end
|
|
|
+ //****************************************************************** end
|
|
|
|
|
|
-//*********************************config
|
|
|
-struct __declspec(dllexport) ufile_config{
|
|
|
- const char *public_key; //json: public_key
|
|
|
- const char *private_key; //json: private_key
|
|
|
+ //*********************************config
|
|
|
+ struct __declspec(dllexport) ufile_config {
|
|
|
+ const char *public_key; //json: public_key
|
|
|
+ const char *private_key; //json: private_key
|
|
|
|
|
|
- const char *file_host; //json: file_host
|
|
|
- const char *bucket_host; //json: bucket_host
|
|
|
- long long appid;
|
|
|
- const char *region;
|
|
|
-};
|
|
|
+ const char *file_host; //json: file_host
|
|
|
+ const char *bucket_host; //json: bucket_host
|
|
|
+ long long appid;
|
|
|
+ const char *region;
|
|
|
+ };
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_load_config_from_json(const char* json_buf, struct ufile_config *cfg);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_load_config_from_json(const char* json_buf, struct ufile_config *cfg);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) void
|
|
|
-ufile_free_config(struct ufile_config cfg);
|
|
|
-//*********************************end config
|
|
|
+ __declspec(dllexport) void
|
|
|
+ ufile_free_config(struct ufile_config cfg);
|
|
|
+ //*********************************end config
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_sdk_initialize(const struct ufile_config cfg, int open_verbose);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_sdk_initialize(const struct ufile_config cfg, int open_verbose);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) void
|
|
|
-ufile_sdk_cleanup();
|
|
|
+ __declspec(dllexport) void
|
|
|
+ ufile_sdk_cleanup();
|
|
|
|
|
|
-//********************************************** file info
|
|
|
+ //********************************************** file info
|
|
|
|
|
|
-struct __declspec(dllexport) ufile_file_info{
|
|
|
- long long bytes_len;
|
|
|
- const char *etag;
|
|
|
- const char *mime_type;
|
|
|
-};
|
|
|
+ struct __declspec(dllexport) ufile_file_info {
|
|
|
+ long long bytes_len;
|
|
|
+ const char *etag;
|
|
|
+ const char *mime_type;
|
|
|
+ };
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_head(const char* bucket_name, const char *key, struct ufile_file_info *info);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_head(const char* bucket_name, const char *key, struct ufile_file_info *info);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) void
|
|
|
-ufile_free_file_info(struct ufile_file_info info);
|
|
|
-//***************************************************
|
|
|
+ __declspec(dllexport) void
|
|
|
+ ufile_free_file_info(struct ufile_file_info info);
|
|
|
+ //***************************************************
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_put_buf(const char* bucket_name, const char *key, const char *mime_type, char *buffer, size_t buf_len);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_put_buf(const char* bucket_name, const char *key, const char *mime_type, char *buffer, size_t buf_len);
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_put_file(const char* bucket_name, const char *key, const char *mime_type, FILE *file);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_put_file(const char* bucket_name, const char *key, const char *mime_type, FILE *file);
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_put_file_by_filepath(const char* bucket_name, const char *key, const char *mime_type, const char*file_path);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_put_file_by_filepath(const char* bucket_name, const char *key, const char *mime_type, const char*file_path);
|
|
|
|
|
|
-enum{
|
|
|
- company_ucloud, // ucloud
|
|
|
- company_tx, //ÌÚѶ
|
|
|
-};
|
|
|
-__declspec(dllexport) void
|
|
|
-set_upload_company(int company);
|
|
|
+ enum {
|
|
|
+ company_ucloud, // ucloud
|
|
|
+ company_tx, //ÌÚѶ
|
|
|
+ };
|
|
|
+ __declspec(dllexport) void
|
|
|
+ set_upload_company(int company);
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_delete(const char* bucket_name, const char *key);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_delete(const char* bucket_name, const char *key);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_mutipart_state{
|
|
|
+ __declspec(dllexport) struct ufile_mutipart_state {
|
|
|
|
|
|
- const char *bucket_name;
|
|
|
+ const char *bucket_name;
|
|
|
|
|
|
- const char *key;
|
|
|
+ const char *key;
|
|
|
|
|
|
- size_t part_size;
|
|
|
- const char *upload_id;
|
|
|
- struct etag_slist *etags;
|
|
|
- struct curls_list *curls;
|
|
|
-};
|
|
|
+ size_t part_size;
|
|
|
+ const char *upload_id;
|
|
|
+ struct etag_slist *etags;
|
|
|
+ struct curls_list *curls;
|
|
|
+ };
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_multiple_upload_init(struct ufile_mutipart_state *self, const char *bucket_name, const char *key, const char* mime_type);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_multiple_upload_init(struct ufile_mutipart_state *self, const char *bucket_name, const char *key, const char* mime_type);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_multiple_upload_part(struct ufile_mutipart_state *self, char *buffer, size_t buf_len, int part_number);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_multiple_upload_part(struct ufile_mutipart_state *self, char *buffer, size_t buf_len, int part_number);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_multiple_upload_finish(struct ufile_mutipart_state *self);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_multiple_upload_finish(struct ufile_mutipart_state *self);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_multiple_upload_abort(struct ufile_mutipart_state *self);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_multiple_upload_abort(struct ufile_mutipart_state *self);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_download(const char *bucket_name, const char *key, FILE *file, size_t *return_size,const char*path=0);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_download(const char *bucket_name, const char *key, FILE *file, size_t *return_size, const char*path = 0);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_download_piece(const char *bucket_name, const char *key, size_t start_position, char *buf, size_t buf_len, size_t *return_size);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_download_piece(const char *bucket_name, const char *key, size_t start_position, char *buf, size_t buf_len, size_t *return_size);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_bucket_create(const char *bucket_name, const char* region, const char* bucket_type);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_bucket_create(const char *bucket_name, const char* region, const char* bucket_type);
|
|
|
|
|
|
|
|
|
-__declspec(dllexport) struct ufile_error
|
|
|
-ufile_bucket_delete(const char *bucket_name);
|
|
|
+ __declspec(dllexport) struct ufile_error
|
|
|
+ ufile_bucket_delete(const char *bucket_name);
|
|
|
#ifdef __cplusplus
|
|
|
}
|
|
|
#endif
|