11local httplib = require (" pipe.httplib" )
22local strutil = require (" acid.strutil" )
3+ local tableutil = require (" acid.tableutil" )
34local rpc_logging = require (" acid.rpc_logging" )
45local acid_setutil = require (" acid.setutil" )
56local s3_client = require (' resty.aws_s3.client' )
@@ -261,7 +262,7 @@ function _M.make_quorum_http_writers(dests, writer_opts, quorum)
261262 return nil , ' NotEnoughConnect' , to_str (' quorum:' , quorum , " , actual:" , n_ok )
262263end
263264
264- function _M .make_aws_put_s3_writer (access_key , secret_key , endpoint , params , opts )
265+ function _M .make_put_s3_writer (access_key , secret_key , endpoint , params , opts )
265266 local s3_cli , err_code , err_msg =
266267 s3_client .new (access_key , secret_key , endpoint , opts )
267268 if err_code ~= nil then
@@ -275,8 +276,11 @@ function _M.make_aws_put_s3_writer(access_key, secret_key, endpoint, params, opt
275276 end
276277
277278 return function (pobj , ident )
278- local chunk_writer =
279- aws_chunk_writer :new (request .signer , request .auth_ctx )
279+ local chunk_writer
280+ if opts .aws_chunk == true then
281+ chunk_writer =
282+ aws_chunk_writer :new (request .signer , request .auth_ctx )
283+ end
280284
281285 local _ , err_code , err_msg = s3_cli :send_request (
282286 request .verb , request .uri , request .headers ,request .body )
@@ -290,8 +294,12 @@ function _M.make_aws_put_s3_writer(access_key, secret_key, endpoint, params, opt
290294 return nil , err_code , err_msg
291295 end
292296
293- local chunked_data = chunk_writer :make_chunk (data )
294- local _ , err_code , err_msg = s3_cli :send_body (chunked_data )
297+ local send_data = data
298+ if opts .aws_chunk == true then
299+ send_data = chunk_writer :make_chunk (send_data )
300+ end
301+
302+ local _ , err_code , err_msg = s3_cli :send_body (send_data )
295303 if err_code ~= nil then
296304 return nil , err_code , err_msg
297305 end
@@ -305,4 +313,11 @@ function _M.make_aws_put_s3_writer(access_key, secret_key, endpoint, params, opt
305313 end
306314end
307315
316+ function _M .make_aws_put_s3_writer (access_key , secret_key , endpoint , params , opts )
317+ opts = tableutil .dup (opts or {}, true )
318+ opts .aws_chunk = true
319+
320+ return _M .make_put_s3_writer (access_key , secret_key , endpoint , params , opts )
321+ end
322+
308323return _M
0 commit comments