我正在开发一个 iPhone 应用程序,如果我需要将图像上传到文件夹中。我正在从保存的相册中获取图像并将其保存在文件夹中。我想上传该图像,但出现错误。
这是我的代码
NSMutableArray *array=[[NSMutableArray alloc]init];
NSString *folderName;
if (metadata.isDirectory) {
NSLog(@"Folder '%@' contains:", metadata.path);
for (DBMetadata *file in metadata.contents)
{
[array addObject:file.filename];
NSLog(@"\t%@", file.filename);
}
folderName=[array objectAtIndex:0];
}
NSString *pngImagePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",imageName.text]];
[data writeToFile:pngImagePath atomically:YES];
[[self restClient]uploadFile:[NSString stringWithFormat:@"%@.png",imageName.text] toPath:[NSString stringWithFormat:@"/%@",folderName]withParentRev:nil fromPath:pngImagePath];
我得到以下错误
File upload failed with error - Error Domain=NSURLErrorDomain
Code=-1021 "The operation couldn’t be completed. (NSURLErrorDomain
error -1021.)" UserInfo=0x68d0c70 {destinationPath=/sonal/abc.png,
sourcePath=/Users/bcod/Library/Application Support/iPhone
Simulator/5.0/Applications/44555D9C-422E-45FC-B392-F74275B16378/Documents/abc.png}
我也收到以下警告
[WARNING] DropboxSDK: error making request to
/1/files_put/dropbox/apple/app.png
请任何人都可以告诉我为什么会出现此错误
提前致谢