provokateurin / dart-nextcloud

A Nextcloud client for dart
Other
20 stars 15 forks source link

fix mkdirs not working #58

Closed PascalOtto closed 2 years ago

PascalOtto commented 2 years ago

fixes #57

provokateurin commented 2 years ago

sorry this library is a mess and the tests are broken. see https://github.com/jld3103/dart-nextcloud/issues/55

pastordee commented 2 years ago

Hi guys I got mine to work by using the mkdir and saving the one folder at time. var userId = "${globals.currentUser!.objectId!}"; String user= 'Users'; String userId = 'Users/$userId'; String finalFolder = 'Users/$userId/profile_pics'; then I save the file. await client.webDav.upload(image.readAsBytesSync(), '$finalFolder/avatar.jpg')

So I think in the mkdirs we have to find a way to get it to loop through everything and save it one by one. If you were saving up to 2 levels of folder it will be something like this

Future mkdirs(String path) async { path = path.trim(); final dirs = path.split('/')..removeWhere((value) => value == ''); if (dirs.isEmpty) { return; } if (path.startsWith('/')) { dirs[0] = '/${dirs[0]}'; } await mkdir(dirs[0]); var increment = 1; for (final dir in dirs) { await mkdir(dirs[0]+'/'+dirs[increment]); increment++; } }

provokateurin commented 2 years ago

Fixed in https://github.com/jld3103/nextcloud-harbour/blob/7951dc263975e000b83ddb1d703d8cbfaead1180/packages/nextcloud/lib/src/clients/custom/webdav/client.dart