From 83f4ce9c463b29988b2dbf2384b9915ef9334e56 Mon Sep 17 00:00:00 2001 From: pengxuanzheng Date: Sun, 27 Sep 2020 11:58:23 +0800 Subject: update --- src/hos_client.cpp | 24 +++++++++++++++++------- src/hos_client.h | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/hos_client.cpp b/src/hos_client.cpp index 797a075d..659db6c5 100644 --- a/src/hos_client.cpp +++ b/src/hos_client.cpp @@ -87,14 +87,11 @@ hos_client_handle hos_client_create(const char *endpoint, const char *accesskeyi Aws::Client::ClientConfiguration config; Aws::Auth::AWSCredentials credentials(accesskeyid, secretkey); + //初始化 config.endpointOverride = endpoint; config.verifySSL = false; config.enableEndpointDiscovery = true; - //std::shared_ptr pooled_thread = Aws::MakeShared("ClientConfigration"); - //std::shared_ptr test = std::make_shared(1000); - //config.executor(Aws::MakeShared("ClientConfiguration")); - //config.executor = std::dynamic_pointer_cast(config.executor); - config.executor = std::shared_ptr(std::make_shared(100)); + config.executor = std::shared_ptr(std::make_shared(100));//支持线程池 handle->S3Client = new Aws::S3::S3Client(credentials, config, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false); handle->append_size = 30 * 1024 * 1024; @@ -250,11 +247,12 @@ int hos_open_fd(hos_client_handle handle, const char *bucket, const char *object return fd; } -int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id) +int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id, size_t position) { struct stat buffer; hos_info_t *hos_info = NULL; hos_client_handle handle = NULL; + char num[128]; char buf[128]; if ((fd == 0) || (stream == NULL) || (thread_id > MAX_THREAD_NUM)) { @@ -276,12 +274,24 @@ int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id request.SetKey(hos_info->object); //TODO APPEND MODE + snprintf(num, 128, "%lu", position); + Aws::Map headers; + if (hos_info->mode & APPEND_MODE) + { + headers["x-hos-upload-type"] = "append"; + headers["x-hos_position"] = num; + request.SetMetadata(headers); +#if 0 + request.AddMetadata("x-hos-upload-type", "append"); + request.AddMetadata("x-hos-position", num); +#endif + } //设置上传数据类型 if (hos_info->mode & BUFF_MODE) { //BUFF_MODE -#if 0 +#if 1 const std::shared_ptr input_data = Aws::MakeShared(stream, stream + stream_len); Aws::String buffer (stream, stream_len); diff --git a/src/hos_client.h b/src/hos_client.h index f00a255b..961539ea 100644 --- a/src/hos_client.h +++ b/src/hos_client.h @@ -134,7 +134,7 @@ int hos_open_fd(hos_client_handle handle, const char *bucket, const char *object * size_t thread_id 线程ID * 返回值 int 成功返回0,失败返回hoserros错误码 *************************************************************************************/ -int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id); +int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id, size_t position); /************************************************************************************* * 函数名: hos_close_fd * 参数: size_t fd fd -- cgit v1.2.3