Objective c How Carrierwave“;图像可以';“不要空白”;不允许您上传\&引用;文件夹?

Objective c How Carrierwave“;图像可以';“不要空白”;不允许您上传\&引用;文件夹?,objective-c,carrierwave,image-uploading,afhttpclient,Objective C,Carrierwave,Image Uploading,Afhttpclient,我要走了 (lldb)采购订单操作。响应预算 {“错误”:{“图像”:[“不能为空”,“不允许上载\“\”文件,允许的类型:jpg、jpeg、gif、png”]} 上载以使用图像参数以及名称和说明创建新组 NSString *path = [NSString stringWithFormat:@"api/group?name=%@&description=%@&auth_token=%@", name, desc,[AccountService authToken]];

我要走了

(lldb)采购订单操作。响应预算 {“错误”:{“图像”:[“不能为空”,“不允许上载\“\”文件,允许的类型:jpg、jpeg、gif、png”]}

上载以使用图像参数以及名称和说明创建新组

    NSString *path = [NSString stringWithFormat:@"api/group?name=%@&description=%@&auth_token=%@", name, desc,[AccountService authToken]];


NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [RequestHelpers basePath]]];

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];

NSData *imageData = UIImageJPEGRepresentation(image, 0.25f);
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:path parameters:@{} constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    NSString *fileName = [NSString stringWithFormat:@"%@", [[NSDate date] description]];
    [formData appendPartWithFileData:imageData name:@"image" fileName:fileName mimeType:@"image/jpeg"];
}];


AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    [self.delegate createdGroupSuccessfully];;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    [self handleOperationFailed:operation action:^{
           //handle failed request
    }];
}];
NSString*path=[NSString stringWithFormat:@“api/group?name=%@&description=%@&auth_token=%@”,name,desc,[AccountService authToken];
NSURL*url=[NSURL URLWithString:[NSString stringWithFormat:@“%@,[RequestHelpers basePath]];
AFHTTPClient*httpClient=[[AFHTTPClient alloc]initWithBaseURL:url];
NSData*imageData=UIIMAGEJPEG表示法(图像,0.25f);
NSMutableURLRequest*request=[httpClient multipartFormRequestWithMethod:@“POST”路径:路径参数:@{}constructingBodyWithBlock:^(id formData){
NSString*文件名=[NSString stringWithFormat:@“%@,[[NSDate date]说明]];
[formData appendPartWithFileData:imageData名称:@“图像”文件名:文件名mimeType:@“图像/jpeg”];
}];
AFHTTPRequestOperation*操作=[[AFHTTPRequestOperation alloc]initWithRequest:request];
[操作setCompletionBlockWithSuccess:^(AFHTTPRequestOperation*操作,id响应对象){
[self.delegate已成功创建组];;
}失败:^(AFHTTPRequestOperation*操作,NSError*错误){
[自助操作失败:操作操作:^{
//处理失败的请求
}];
}];

我是否需要更改Carrierwave设置,或者我的obj-c代码中缺少什么内容?

名称中的空格有问题。我使用obj-c函数获取时间戳作为文件名。

名称中存在空格问题。我使用了一个obj-c函数来获取时间戳作为文件名。

很难说这一点。你能像params一样附加rails应用程序的请求头吗?很难说这能像params一样附加rails应用程序的请求头吗