diff --git a/b0esche_cloud/lib/blocs/upload/upload_bloc.dart b/b0esche_cloud/lib/blocs/upload/upload_bloc.dart index 7681bb3..25c871f 100644 --- a/b0esche_cloud/lib/blocs/upload/upload_bloc.dart +++ b/b0esche_cloud/lib/blocs/upload/upload_bloc.dart @@ -24,8 +24,12 @@ class UploadBloc extends Bloc { for (final file in event.files) { try { - print('[UploadBloc] Starting upload for ${file.name} to orgId=${event.orgId}, path=${file.path}'); - print('[UploadBloc] File bytes: ${file.bytes?.length ?? 0} bytes, localPath: ${file.localPath}'); + print( + '[UploadBloc] Starting upload for ${file.name} to orgId=${event.orgId}, path=${file.path}', + ); + print( + '[UploadBloc] File bytes: ${file.bytes?.length ?? 0} bytes, localPath: ${file.localPath}', + ); // Simulate upload await _fileRepository.uploadFile(event.orgId, file); print('[UploadBloc] Upload successful for ${file.name}'); diff --git a/b0esche_cloud/lib/services/file_service.dart b/b0esche_cloud/lib/services/file_service.dart index fbd8906..a3ee43e 100644 --- a/b0esche_cloud/lib/services/file_service.dart +++ b/b0esche_cloud/lib/services/file_service.dart @@ -52,11 +52,17 @@ class FileService { // If bytes or localPath available, send multipart upload with field 'file' final Map fields = {'path': file.path}; FormData formData; - print('[FileService] uploadFile: file=${file.name}, path=${file.path}, orgId=$orgId'); - print('[FileService] bytes=${file.bytes?.length ?? 0}, localPath=${file.localPath}'); - + print( + '[FileService] uploadFile: file=${file.name}, path=${file.path}, orgId=$orgId', + ); + print( + '[FileService] bytes=${file.bytes?.length ?? 0}, localPath=${file.localPath}', + ); + if (file.bytes != null) { - print('[FileService] Using bytes for upload (${file.bytes!.length} bytes)'); + print( + '[FileService] Using bytes for upload (${file.bytes!.length} bytes)', + ); formData = FormData.fromMap({ ...fields, 'file': MultipartFile.fromBytes(file.bytes!, filename: file.name), @@ -69,7 +75,9 @@ class FileService { }); } else { // Fallback to metadata-only create (folders or client that can't send file content) - print('[FileService] No bytes or localPath; falling back to metadata-only'); + print( + '[FileService] No bytes or localPath; falling back to metadata-only', + ); final data = { 'name': file.name, 'path': file.path, @@ -90,11 +98,7 @@ class FileService { final endpoint = orgId.isEmpty ? '/user/files' : '/orgs/$orgId/files'; print('[FileService] Uploading to endpoint: $endpoint'); - await _apiClient.post( - endpoint, - data: formData, - fromJson: (d) => null, - ); + await _apiClient.post(endpoint, data: formData, fromJson: (d) => null); print('[FileService] Upload completed for ${file.name}'); }