Hokay, so, here’s what seems to be working for me:
- get your file (name and data)
- isolate and url encode the filename (somefile.jpg)
- base64 encode the filedata
- put the filename into array1[filename]
- put the filedata into array1[contents]
- put “false” into array1[private] (I haven’t tried making it private and attached to a database thing yet)
- put that array into array2[file] (I tried changing that but the server stopped accepting it, so apparently it has to be “file”)
- put anything else you need into array2[], for example “some example text” into array2[example]
- convert array to JSON (as required) what you end up with is something like this:
array2={
file={filename=file’s-name.jpg, private=false, contents=base64}
example=some example text
} - setup your API to recognize the “file” parameter as a file and the “example” parameter as text
- change the headers to “Content-Type: application/json”