我需要把我的形象在我的iphone app.I到Salesforce已經嘗試那些東西 轉換的圖像 - >字節 - > base64編碼然後存儲SFDC(豐富的數據字段),它是完全可以做到的,但我需要保存爲圖像。這裏是我的如下代碼(它不工作) 引導我如何實現這一發送附件到Salesforce通過iOS原生一個REST SDK
NSData *imageData = UIImagePNGRepresentation(imageView.image);
NSString *boundary = @"---------------------------14737809831466499882746641449";
SFRestRequest *request = [[SFRestRequest alloc] init];
[request setDelegate:self];
[request setEndpoint:kSFDefaultRestEndpoint];
[request setMethod:SFRestMethodPOST];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"rn--%@rn",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Content- Disposition: form-data; name=\"entity_document\"; filename=\"%@\"\r\n",@"Test.png"]] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: multipart/form-data\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Description :\"%s\"\r\n","Marketing brochure for Q1 2011"]] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Keywords :\"%s\"\r\n","marketing,sales,update"]] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"FolderId :\"%s\"\r\n","005D0000001GiU7"]] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Name :\"%s\"\r\n","Marketing Brochure Q1"]] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"rn--%@--rn",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSString *attbody = [NSString stringWithFormat:@"{\"body\" : {\"Name\" :[{ \"type\" : \"image/jpeg\", \"image\" : \"%@\"}] } }",body];
[request setPath:[NSString stringWithFormat:@"/v23.0/sobjects/Document/"]];
[request setQueryParams:(NSDictionary *)[SFJsonUtils objectFromJSONString:attbody]];
[[SFRestAPI sharedInstance] send:request delegate:self];
有需要的任何類(APEX)處理我的請求?
你是什麼意思關於圖像保存?在銷售隊伍文件或附件什麼的? –
什麼,我需要從我的iPhone發送圖像SFDC? – Rams
那什麼不起作用?你看到什麼錯誤? –