/
handler.cfm
61 lines (61 loc) · 1.78 KB
/
handler.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<cfscript>
Aviary = new com.aviary(api_key=application.api_key,secret=application.secret,response_format="xml");
// switch call to api, depending on requested method
switch(form.method) {
// upload
case "upload":
tmpresult = Aviary.upload(file=form.file);
writeoutput(Aviary.formatupload(tmpresult));
break;
// renderoptions
case "renderoptions":
// setup argument collection
args = {
backgroundcolor=form.backgroundcolor,
format=form.format,
quality=form.quality,
scale=form.scale,
filepath=form.filepath,
filterid=form.filterid,
cols=form.cols,
rows=form.rows,
cellwidth=form.cellwidth,
cellheight=form.cellheight,
calltype=form.calltype
};
// make intial api call
tmpresult = Aviary.renderoptions(argumentcollection=args);
// call custom formatting method (to parse xml string into CF structure)
result = Aviary.formatrenderoptions(tmpresult);
// return serialized version of CF array
writeoutput(serializejson(result));
break;
// render
case "render":
// setup argument collection
args = {
backgroundcolor=form.backgroundcolor,
format=form.format,
quality=form.quality,
scale=form.scale,
filepath=form.filepath,
filterid=form.filterid,
cols=form.cols,
rows=form.rows,
cellwidth=form.cellwidth,
cellheight=form.cellheight,
calltype=form.calltype,
renderparameters = Aviary.createrenderparameterxml(deserializejson(form.renderparameters))
};
// make initial api call
tmpresult = Aviary.render(argumentcollection=args);
// call custom formatting method (to parse xml string into CF object)
result = Aviary.formatrender(tmpresult);
// return
writeoutput(result);
break;
// get filters...maybe someday?
case "getfilters":
break;
}
</cfscript>