Dropbox restClient只保存文件。所以我想先將圖像保存在本地文件夾中,然後將其上傳,從而保存文件,但已損壞。如何將未保存在設備上的圖像上傳到保管箱賬戶?(IOS)
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSString *jpegFilePath = [NSString stringWithFormat:@"%@/test.jpeg",localPath];
NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data2 writeToFile:jpegFilePath atomically:YES];
NSString *filename = @"test.jpeg";
NSString *destDir = @"/";
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
我是個白癡,解決
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingString:@"test.jpg"];
NSData * data = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data writeToFile:path atomically:YES];
[self.restClient uploadFile:@"test.jpg" toPath:@"/" withParentRev:nil fromPath:path];
結果是否因正確的大小或錯誤的大小或空的或...而損壞? –
大小等於:1,012字節,所以它錯了 –