yuchanns commented on code in PR #7647:
URL: https://github.com/apache/opendal/pull/7647#discussion_r3331957410


##########
bindings/go/writer.go:
##########
@@ -57,6 +58,196 @@ func (op *Operator) Write(path string, data []byte) error {
        return ffiOperatorWrite.symbol(op.ctx)(op.inner, path, data)
 }
 
+// WithWriteFn is a functional option for write operations.
+type WithWriteFn func(*writeOptions)
+
+// WriteWithAppend sets append mode for the write operation.
+func WriteWithAppend(append bool) WithWriteFn {
+       return func(o *writeOptions) {
+               o.append = append
+       }
+}
+
+// WriteWithCacheControl sets the Cache-Control header for the write operation.
+func WriteWithCacheControl(cacheControl string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.cacheControl = cacheControl
+       }
+}
+
+// WriteWithContentType sets the Content-Type header for the write operation.
+func WriteWithContentType(contentType string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.contentType = contentType
+       }
+}
+
+// WriteWithContentDisposition sets the Content-Disposition header for the 
write operation.
+func WriteWithContentDisposition(contentDisposition string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.contentDisposition = contentDisposition
+       }
+}
+
+// WriteWithContentEncoding sets the Content-Encoding header for the write 
operation.
+func WriteWithContentEncoding(contentEncoding string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.contentEncoding = contentEncoding
+       }
+}
+
+// WriteWithUserMetadata sets user metadata for the write operation.
+func WriteWithUserMetadata(userMetadata map[string]string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.userMetadata = userMetadata
+       }
+}
+
+// WriteWithIfMatch sets the If-Match condition for the write operation.
+func WriteWithIfMatch(ifMatch string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.ifMatch = ifMatch
+       }
+}
+
+// WriteWithIfNoneMatch sets the If-None-Match condition for the write 
operation.
+func WriteWithIfNoneMatch(ifNoneMatch string) WithWriteFn {
+       return func(o *writeOptions) {
+               o.ifNoneMatch = ifNoneMatch
+       }
+}
+
+// WriteWithIfNotExists sets whether the write operation should only succeed 
if the target does not exist.
+func WriteWithIfNotExists(ifNotExists bool) WithWriteFn {
+       return func(o *writeOptions) {
+               o.ifNotExists = ifNotExists
+       }
+}
+
+// WriteWithConcurrent sets concurrent write operations.
+func WriteWithConcurrent(concurrent uint) WithWriteFn {
+       return func(o *writeOptions) {
+               o.concurrent = concurrent
+       }
+}
+
+// WriteWithChunk sets the chunk size for buffered writes.
+func WriteWithChunk(chunk uint) WithWriteFn {
+       return func(o *writeOptions) {
+               o.chunk = chunk
+       }
+}
+
+type writeOptions struct {
+       append             bool
+       cacheControl       string
+       contentType        string
+       contentDisposition string
+       contentEncoding    string
+       userMetadata       map[string]string
+       ifMatch            string
+       ifNoneMatch        string
+       ifNotExists        bool
+       concurrent         uint
+       chunk              uint
+}
+
+// WriteWith writes the given bytes to the specified path with options.
+func (op *Operator) WriteWith(path string, data []byte, opts ...WithWriteFn) 
error {

Review Comment:
   Can we merge `WriteWith` into `Write`?



##########
bindings/go/writer.go:
##########
@@ -136,6 +327,26 @@ func (op *Operator) Writer(path string) (*Writer, error) {
        return writer, nil
 }
 
+// WriterWith returns a new Writer for the specified path with options.
+func (op *Operator) WriterWith(path string, opts ...WithWriteFn) (*Writer, 
error) {

Review Comment:
   Same question applies here.



-- 
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]

Reply via email to