在Dropbox上传图片时出错

时间:2013-04-19 06:17:54

标签: iphone ios dropbox

我正在开发一个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

请有人告诉我为什么会收到此错误

提前致谢

1 个答案:

答案 0 :(得分:0)

检查目标路径..似乎问题是服务器无法找到目标文件夹

还要检查图像大小。大文件可能导致它耗尽请求。尝试使用较小的图像