Archived from the Transloadit support forum. Originally posted on December 20, 2010; details may be outdated, see our docs for current behavior. Original thread
In the case of an upload via a web form, we have the choice between sending “params” as form data, or “template_id” as form data.
In the iphone SDK only “template_id” is available.
This is a problem for my application where I cannot use a template because the notify url contains a user_id that is specific to each upload, and thus cannot be part of a template (except if template accept variables, which I am not aware of?)
How can I send this via the SDK?
I think I need to give the iPhone SDK a little love : ). I’ll be working on it today and update the ticket here.
Alright, I had a look and it turns out the sdk can already do what you need. I did however add new example to the documentation:
https://github.com/transloadit/iphone-sdk/commit/REDACTED
Also: You can specify a template_id and params at the same time. The params will be recursively merged into your template.
Let me know if this helps!
--fg
Hi, I looked at the example. Would you be able to provide a downloadable example that I can build? I tried out your tweak to add params but got build errors where I needed to define resizestep and step. I defined them higher up but it would help ease the mind if you had an example that passes params that can build.
Thanks.
Hi, I’m really sorry - I forgot to add the declaration for those two variables to the example:
https://github.com/transloadit/iphone-sdk/commit/REDACTED
Let me know if it works now!
Thanks so much for the help… I got the code to compile and I just tried uploading. What I got was the following error:
-JSONValue failed. Error trace is: ( “Error Domain=org.brautaset.JSON.ErrorDomain Code=3 “Unrecognised leading character” UserInfo=0x10c1c0 {NSLocalizedDescription=Unrecognised leading character}”
When I outputted what I was sending, I am sending the following:
{ resize = { robot = “/image/resize”; use = “:original”; width = 90; }; store = { bucket = “cutiesafari_us_test”; key = REDACTED; robot = “/s3/store”; secret = “7QO93k/IcNE+ip1VfEnU02/j9ENpZuFBLgMvzfFg”; }; }
I know that I need to add comas to separate out each value pair, but how about the extra semi-colons? How do I remove those?
Thanks again.
Hi Felix,
This is working for one rule, when I put more rules, it keeps putting the store at the beginning of the assembly!
here is my code:
NSMutableDictionary *steps = [[NSMutableDictionary alloc] init];
NSMutableDictionary *resizeStep = [[NSMutableDictionary alloc] init];
NSMutableDictionary *store = [[NSMutableDictionary alloc] init];
[[transload params] setObject:strNotifyURL forKey:@"notify_url"];
[[transload params] setObject:steps forKey:@"steps"];
[steps setObject:resizeStep forKey:@"resize"];
[steps setObject:store forKey:@"store"];
[store setObject:strTransLoadItSecret forKey:@"secret"];
[store setObject:@"..." forKey:@"key"];
[store setObject:@"cutiesafari_us_test" forKey:@"bucket"];
[store setObject:@"/s3/store" forKey:@"robot"];
[store setObject:@"resize" forKey:@"use"];
[resizeStep setObject:[NSNumber numberWithInt:90] forKey:@"width"];
[resizeStep setObject:@"/image/resize" forKey:@"robot"];
[resizeStep setObject:@":original" forKey:@"use"];
And the result of the assembly:
https://transloadit.com/assemblies/view/REDACTED
You can see store is before resize, so it does not work.
Of course I tried to revert the setObject and do:
[steps setObject:store forKey:@"store"];
[steps setObject:resizeStep forKey:@"resize"];
But no luck…
Any idea?
That’s probably a problem with the JSON library we use, and it doesn’t sound like it’s going to be easy to fix. JSON itself says ordering on the keys isn’t guaranteed, so it’s compliant with the spec.
The solution is to set an explicit "use": "step" parameter, this way your assembly steps can be ordered without relying on the order send via JSON.
Let me know if that makes!
Hey Felix,
The store is using a use of resize.
AFAIK this means that the store step depends on the step.
Any idea what’s going on then?
[store setObject:@"resize" forKey:@"use"];
Hi Brian,
the code looks good to me, I’m not sure I understand the problem. Can you explain this differently?
--fg
Your suggestion for a fix in post 8 to the problem in post 7 is already a part of post 7.
Brian: You’re right, I missed that in stanislas’ comment.
However, looking at his assembly, the problem was that there was no file uploaded.
About the ordering: The "use" parameter will make sure that the files are processed int he right order, however, it has no effect on how the steps are ordered in the resulting JSON.
What problem are you running into Brian?