Closed PascalOtto closed 2 years ago
sorry this library is a mess and the tests are broken. see https://github.com/jld3103/dart-nextcloud/issues/55
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++; } }
fixes #57