ios

时间:2015-05-14 06:35:39

标签: ios objective-c transloadit

在上传太小尺寸的图像时,例如,当裁剪图像时,T​​ransloadit服务器始终会回复此响应。

{"error":"FILE_FILTER_DECLINED_FILE","message":"One of your files was declined","reason":"file_0"}

我还尝试使用 force_accept 参数在ASSEMBLY中添加STEP来测试响应,考虑(希望)它将接受任何文件大小。但仍然得到相同的回应。

以下是代码段:

Transloadit *transloadit = [[Transloadit alloc]init:TRANSLOADIT_API_KEY];
AssemblyBuilder *assembly = [[AssemblyBuilder alloc]init];
[assembly setTemplateID:TRANSLOADIT_TEMPLATE_ID];
NSData *imgData = UIImageJPEGRepresentation(imageToUpload, 1.0f);
NSError* error;


//Add a file to be uploaded with autogenerated key
[assembly addFile:imgData withError:error];
if(error!=nil)
    TRANSLOADIT_LOG_ERROR(self.class,error);

NSObject<IStep>* step=[[Step alloc] init];
[step setOptionKey:@"robot" object:@"/image/resize"];
[step setOptionKey:@"width" object:@(75)];
[step setOptionKey:@"height" object:@(75)];
[step setOptionKey:@"resize_strategy" object:@"pad"];
[step setOptionKey:@"background" object:@"#000000"];
[step setOptionKey:@"force_accept" object:[NSNumber numberWithBool:YES]];


//Add the step to the assembly
[assembly addStepName:@"thumb" step:step];


//Invoke assembly, and wait for the result
TransloaditResponse* response =[transloadit invokeAssembly:assembly withError:error];
if(error!=nil)
{
    TRANSLOADIT_LOG_ERROR_WITH_MESSAGE(self.class,@"Error has occured while completing assembly");
}

if([response isSuccess])
{
     // success code
}
else
{
     // failure code
}

如果有人可以帮助我。谢谢:))

1 个答案:

答案 0 :(得分:1)

只有在使用file/filter机器人限制可以上传的文件时,才会出现此错误。虽然我没有看到您在代码中使用它,但它很可能会在您TRANSLOADIT_TEMPLATE_ID

引用的已保存模板说明中使用。