summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpengxuanzheng <[email protected]>2020-09-27 11:58:23 +0800
committerpengxuanzheng <[email protected]>2020-11-02 18:59:51 +0800
commit83f4ce9c463b29988b2dbf2384b9915ef9334e56 (patch)
tree6d5be217c9044df86568ab88d9e04830c4cf43e6 /src
parent9d2aaa9fa4868f9b28dc4571a964b4b842912bc2 (diff)
update
Diffstat (limited to 'src')
-rw-r--r--src/hos_client.cpp24
-rw-r--r--src/hos_client.h2
2 files changed, 18 insertions, 8 deletions
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<Aws::Utils::Threading::Executor> pooled_thread = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("ClientConfigration");
- //std::shared_ptr<Aws::Utils::Threading::Executor> test = std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(1000);
- //config.executor(Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("ClientConfiguration"));
- //config.executor = std::dynamic_pointer_cast<Aws::Utils::Threading::PooledThreadExecutor>(config.executor);
- config.executor = std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor>(std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(100));
+ config.executor = std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor>(std::make_shared<Aws::Utils::Threading::PooledThreadExecutor>(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<Aws::String, Aws::String> 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<Aws::IOStream> input_data =
Aws::MakeShared<Aws::StringStream>(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