createDirectory method

  1. @override
Future<void> createDirectory(
  1. String path
)
override

Creates a new directory in the cloud storage.

Implementation

@override
Future<void> createDirectory(String path) async {
  _checkAuth();
  try {
    await _dio.post(
      'https://api.dropboxapi.com/2/files/create_folder_v2',
      data: jsonEncode({'path': _normalizePath(path), 'autorename': false}),
      options: Options(contentType: 'application/json'),
    );
  } on DioException catch (e) {
    // Ignore error if the folder already exists.
    if (e.response?.data?['error_summary']
            ?.contains('path/conflict/folder') ==
        false) {
      rethrow;
    }
    debugPrint("Directory already exists, ignoring error.");
  }
}