Xuanwo commented on code in PR #5664:
URL: https://github.com/apache/opendal/pull/5664#discussion_r1976349174
##########
bindings/java/src/async_operator.rs:
##########
@@ -123,23 +126,58 @@ fn intern_write(
executor: *const Executor,
path: JString,
content: JByteArray,
+ options: JObject,
) -> Result<jlong> {
let op = unsafe { &mut *op };
let id = request_id(env)?;
let path = jstring_to_string(env, &path)?;
let content = env.convert_byte_array(content)?;
+ let content_type = get_optional_string_from_object(env, &options,
"getContentType")?;
+ let content_disposition = get_optional_string_from_object(env, &options,
"getContentDisposition")?;
+ let content_encoding = get_optional_string_from_object(env, &options,
"getContentEncoding")?;
+ let cache_control = get_optional_string_from_object(env, &options,
"getCacheControl")?;
+ let if_match = get_optional_string_from_object(env, &options,
"getIfMatch")?;
+ let if_none_match = get_optional_string_from_object(env, &options,
"getIfNoneMatch")?;
+ let append = env.call_method(&options, "isAppend", "()Z", &[])?.z()?;
+ let if_not_exists = env.call_method(&options, "isIfNotExists", "()Z",
&[])?.z()?;
+ let user_metadata = get_optional_map_from_object(env, &options,
"getUserMetadata");
+
+ let mut write_op = op.write_with(&path, content);
+ if let Some(ct) = content_type {
+ write_op = write_op.content_type(&ct);
+ }
+ if let Some(cd) = content_disposition {
+ write_op = write_op.content_disposition(&cd);
+ }
+ if let Some(ce) = content_encoding {
+ write_op = write_op.content_encoding(&ce);
+ }
+ if let Some(cc) = cache_control {
+ write_op = write_op.cache_control(&cc);
+ }
+ if let Some(im) = if_match {
+ write_op = write_op.if_match(&im);
+ }
+ if let Some(inm) = if_none_match {
+ write_op = write_op.if_none_match(&inm);
+ }
+ if let Ok(Some(um)) = user_metadata {
+ write_op = write_op.user_metadata(um);
+ }
+ write_op = write_op.if_not_exists(if_not_exists);
+ write_op = write_op.append(append);
executor_or_default(env, executor)?.spawn(async move {
- let result = do_write(op, path, content).await;
+ let result = do_write(write_op).await;
complete_future(id, result.map(|_| JValueOwned::Void))
});
Ok(id)
}
-async fn do_write(op: &mut Operator, path: String, content: Vec<u8>) ->
Result<()> {
- Ok(op.write(&path, content).await.map(|_| ())?)
+async fn do_write(writer: FutureWrite<impl Future<Output
=opendal::Result<Metadata>>>) -> Result<()> {
Review Comment:
Maybe we can just remove this API? It seems to be used in only one place,
and its signature is longer than its body.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]