updateContents method

Future<bool> updateContents(
  1. String id,
  2. Stream<List<int>> data, {
  3. Map<String, String?>? appProperties,
  4. int? dataLength,
})

Implementation

Future<bool> updateContents(String id, Stream<List<int>> data, {Map<String, String?>? appProperties, int? dataLength}) async{
  if(!await ready()) return false;
  if(dataLength != null && !await hasSpace(dataLength)){
    if(onFull != null) onFull!();
    return false;
  }
  try{
    var fil = await api!.files.update(
      File(
        modifiedTime: DateTime.now(),
        appProperties: appProperties,
      ),
      id,
      uploadMedia: Media(data, dataLength)
    );
    return fil.id != null;
  }catch(e, stack){
    if(e is PlatformException && e.code == "network_error"){
      return false;
    }
    // else if(e is DetailedApiRequestError && e.message == "The user's Drive storage quota has been exceeded."){
    //   if(onFull != null) onFull!();
    //   return false;
    // }
    if(kDebugMode){
      print("updateContents:");
      print("${e.toString()}\n${stack.toString()}");
    }else if (onError != null){
      onError!(e, stack);
    }
    return false;
  }
}