@@ -124,13 +124,27 @@ def save_object(
124
124
A FileObject object representing the saved file, potentially updated.
125
125
126
126
"""
127
- _ = self .fs .put (
128
- file_object .path ,
129
- data ,
130
- use_multipart = use_multipart ,
131
- chunk_size = chunk_size ,
132
- max_concurrency = max_concurrency ,
133
- )
127
+ from obstore .store import LocalStore
128
+
129
+ # Prepare attributes with content_type and custom metadata
130
+ attributes : dict [str , Any ] = {}
131
+ if file_object .content_type :
132
+ attributes ["Content-Type" ] = file_object .content_type
133
+
134
+ # Add any custom metadata from file_object.metadata
135
+ if file_object .metadata :
136
+ attributes .update (file_object .metadata )
137
+
138
+ # LocalStore doesn't support attributes parameter - skip it for local filesystem
139
+ put_params : dict [str , Any ] = {
140
+ "use_multipart" : use_multipart ,
141
+ "chunk_size" : chunk_size ,
142
+ "max_concurrency" : max_concurrency ,
143
+ }
144
+ if not isinstance (self .fs , LocalStore ):
145
+ put_params ["attributes" ] = attributes if attributes else None
146
+
147
+ _ = self .fs .put (file_object .path , data , ** put_params )
134
148
info = self .fs .head (file_object .path )
135
149
file_object .size = cast ("int" , info .get ("size" , file_object .size )) # pyright: ignore
136
150
file_object .last_modified = (
@@ -166,13 +180,27 @@ async def save_object_async(
166
180
A FileObject object representing the saved file, potentially updated.
167
181
168
182
"""
169
- _ = await self .fs .put_async (
170
- file_object .path ,
171
- data ,
172
- use_multipart = use_multipart ,
173
- chunk_size = chunk_size ,
174
- max_concurrency = max_concurrency ,
175
- )
183
+ from obstore .store import LocalStore
184
+
185
+ # Prepare attributes with content_type and custom metadata
186
+ attributes : dict [str , Any ] = {}
187
+ if file_object .content_type :
188
+ attributes ["Content-Type" ] = file_object .content_type
189
+
190
+ # Add any custom metadata from file_object.metadata
191
+ if file_object .metadata :
192
+ attributes .update (file_object .metadata )
193
+
194
+ # LocalStore doesn't support attributes parameter - skip it for local filesystem
195
+ put_params : dict [str , Any ] = {
196
+ "use_multipart" : use_multipart ,
197
+ "chunk_size" : chunk_size ,
198
+ "max_concurrency" : max_concurrency ,
199
+ }
200
+ if not isinstance (self .fs , LocalStore ):
201
+ put_params ["attributes" ] = attributes if attributes else None
202
+
203
+ _ = await self .fs .put_async (file_object .path , data , ** put_params )
176
204
info = await self .fs .head_async (file_object .path )
177
205
file_object .size = cast ("int" , info .get ("size" , file_object .size )) # pyright: ignore
178
206
file_object .last_modified = (
0 commit comments