@@ -135,21 +135,17 @@ async def create_resource(
135135 f"Use PUT /resource/{ existing_entity .id } to update it." ,
136136 )
137137
138- # Get full file path
139- full_path = Path (f"{ config .home } /{ data .file_path } " )
140-
141- # Ensure parent directory exists
142- full_path .parent .mkdir (parents = True , exist_ok = True )
143-
144- # Write content to file
145- checksum = await file_service .write_file (full_path , data .content )
138+ # Cloud compatibility: avoid assuming a local filesystem path.
139+ # Delegate directory creation + writes to FileService (local or S3).
140+ await file_service .ensure_directory (Path (data .file_path ).parent )
141+ checksum = await file_service .write_file (data .file_path , data .content )
146142
147143 # Get file info
148- file_metadata = await file_service .get_file_metadata (full_path )
144+ file_metadata = await file_service .get_file_metadata (data . file_path )
149145
150146 # Determine file details
151147 file_name = Path (data .file_path ).name
152- content_type = file_service .content_type (full_path )
148+ content_type = file_service .content_type (data . file_path )
153149 entity_type = "canvas" if data .file_path .endswith (".canvas" ) else "file"
154150
155151 # Create a new entity model
@@ -234,30 +230,27 @@ async def update_resource(
234230 "Path must be relative and stay within project boundaries." ,
235231 )
236232
237- # Get full paths
238- new_full_path = Path (f"{ config .home } /{ target_file_path } " )
239-
240233 # If moving file, handle the move
241234 if data .file_path and data .file_path != entity .file_path :
242- # Ensure new parent directory exists
243- new_full_path . parent . mkdir ( parents = True , exist_ok = True )
235+ # Ensure new parent directory exists (no-op for S3)
236+ await file_service . ensure_directory ( Path ( target_file_path ). parent )
244237
245238 # If old file exists, remove it via file_service (for cloud compatibility)
246239 if await file_service .exists (entity .file_path ):
247240 await file_service .delete_file (entity .file_path )
248241 else :
249242 # Ensure directory exists for in-place update
250- new_full_path . parent . mkdir ( parents = True , exist_ok = True )
243+ await file_service . ensure_directory ( Path ( target_file_path ). parent )
251244
252245 # Write content to target file
253- checksum = await file_service .write_file (new_full_path , data .content )
246+ checksum = await file_service .write_file (target_file_path , data .content )
254247
255248 # Get file info
256- file_metadata = await file_service .get_file_metadata (new_full_path )
249+ file_metadata = await file_service .get_file_metadata (target_file_path )
257250
258251 # Determine file details
259252 file_name = Path (target_file_path ).name
260- content_type = file_service .content_type (new_full_path )
253+ content_type = file_service .content_type (target_file_path )
261254 entity_type = "canvas" if target_file_path .endswith (".canvas" ) else "file"
262255
263256 # Update entity
0 commit comments