You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "jokester (via GitHub)" <gi...@apache.org> on 2023/10/08 16:24:25 UTC

[I] Capability to set contentType not available in python binding [incubator-opendal]

jokester opened a new issue, #3242:
URL: https://github.com/apache/incubator-opendal/issues/3242

   *I don't know much rust or python please don't pull full trust in me.*
   
   When trying to use opendal in a python project I failed to find a way to set `contentType` when uploading a file to Object Storage service like GCS.
   
   After investigated the `core` code it seems to me that,
   
   1. in `core` the capability is provided via `BlockingOperator.{write_with,writer_with}`  `Operator.{write_with,writer_with}`
   2. such capability is not exposed to python binding


-- 
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: commits-unsubscribe@opendal.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Capability to set contentType not available in python binding [incubator-opendal]

Posted by "jokester (via GitHub)" <gi...@apache.org>.
jokester commented on issue #3242:
URL: https://github.com/apache/incubator-opendal/issues/3242#issuecomment-1752109605

   No problem for me. I don't use much python either so I'll try to be very open to your comments 👍🏽 


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Capability to set contentType not available in python binding [incubator-opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #3242:
URL: https://github.com/apache/incubator-opendal/issues/3242#issuecomment-1752108162

   This design seems not native to python users. Maybe we can accept kwargs instead in python, so users can write code like:
   
   ```python
   op.write(path, blob, content_type="image/png")
   ```


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Capability to set contentType not available in python binding [incubator-opendal]

Posted by "jokester (via GitHub)" <gi...@apache.org>.
jokester commented on issue #3242:
URL: https://github.com/apache/incubator-opendal/issues/3242#issuecomment-1752107650

   > Would you like to share the design for implementing `write_with` in Python before makeing a PR?
   
   Sure. Like you I considered to add a `write_method` because there is already `write` in py binding.
   
   I guess the changes will be this shape:
   
   ```diff
   diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs
   index 2d90c602..1887993e 100644
   --- a/bindings/python/src/lib.rs
   +++ b/bindings/python/src/lib.rs
   @@ -124,6 +124,11 @@ impl Operator {
            self.0.write(path, bs).map_err(format_pyerr)
        }
    
   +    pub fn write_with(&self, path: &str, bs: Vec<u8>) -> PyResult<FunctionWrite> {
   +        todo!()
   +    }
   +
        /// Get current path's metadata **without cache** directly.
        pub fn stat(&self, path: &str) -> PyResult<Metadata> {
            self.0.stat(path).map_err(format_pyerr).map(Metadata)
   @@ -200,6 +205,13 @@ impl Reader {
        }
    }
    
   +#[pyclass(module = "opendal")]
   +struct FunctionWrite(od::operator_functions::FunctionWrite);
   +
   +impl FunctionWrite {
   +    // ... expose inner capabilities to python
   +}
   
   
   ```
   
   And some similar changes to `AsyncOperator`. 
   
   Finally in python we can write like:
   
   ```py
   operator.write_with(path, blob).content_type("image/png").call()


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Capability to set contentType not available in python binding [incubator-opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #3242:
URL: https://github.com/apache/incubator-opendal/issues/3242#issuecomment-1752101015

   Would you like to share the design for implementing `write_with` in Python?


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Capability to set contentType not available in python binding [incubator-opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo closed issue #3242: Capability to set contentType not available in python binding
URL: https://github.com/apache/incubator-opendal/issues/3242


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Capability to set contentType not available in python binding [incubator-opendal]

Posted by "jokester (via GitHub)" <gi...@apache.org>.
jokester commented on issue #3242:
URL: https://github.com/apache/incubator-opendal/issues/3242#issuecomment-1752099225

   If this is confirmed I'm happy to try making a PR. I still want to use opendal and this actually blocks my work.


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org