objective c - How to Upload file to google drive only if it is not exist? -


i use xcode develope iphone application.

i upload database files google drive code.

- (void)uploaddb{     gtldrivefile *file = [gtldrivefile object];     file.title = [nsstring  stringwithformat:@"user:%@db.sqlite",username];     file.descriptionproperty = @"uploaded  ios ";     file.mimetype = @"application/x-sqlite3";       // attach db file email      nsarray *paths = nssearchpathfordirectoriesindomains     (nsdocumentdirectory, nsuserdomainmask, yes);      nsstring *documentsdirectory = [paths objectatindex:0];      //make file name write data using documents directory:     nsstring *filename = [nsstring stringwithformat:@"%@/%@",                           documentsdirectory,db_file];     nsdata   *data = [nsdata datawithcontentsoffile:filename];       gtluploadparameters *uploadparameters = [gtluploadparameters uploadparameterswithdata:data mimetype:file.mimetype];     gtlquerydrive *query = [gtlquerydrive queryforfilesinsertwithobject:file                                                        uploadparameters:uploadparameters];      uialertview *waitindicator = [self showwaitindicator:@"uploading google drive"];      [self.driveservice executequery:query                   completionhandler:^(gtlserviceticket *ticket,                                       gtldrivefile *insertedfile, nserror *error) {                       [waitindicator dismisswithclickedbuttonindex:0 animated:yes];                       if (error == nil)                       {                           nslog(@"file id: %@", insertedfile.identifier);                           [self showalert:@"google drive" message:@"file saved!"];                       }                       else                       {                           nslog(@"an error occurred: %@", error);                           [self showalert:@"google drive" message:@"sorry, error occurred!"];                       }                   }];  } 

my problem save new file, wand check if file name exist on drive , replace it.

thanks

the title of file in drive not unique. instead, should use resource id. first time upload database file, remember resource id gives on success , update on.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -