I am trying to use uploadcare.com to manage and save pictures taking from within the app using a phones camera, but am struggling a bit to make create the upload form work.
Here is what I have so far:
// Encode texture into PNG
byte[] bytes = testImage.EncodeToPNG();
string encodedImage = Convert.ToBase64String(bytes);
// Create a Web Form
WWWForm form = new WWWForm();
form.AddField("UPLOADCARE_PUB_KEY", "xxxxxxxxxxxxxxxxxxxx");
form.AddField("UPLOADCARE_STORE", "1");
form.AddField("testfile.png", encodedImage);
using (UnityWebRequest www = UnityWebRequest.Post("https://upload.uploadcare.com/base/", form))
{
yield return www.SendWebRequest();
if (www.result != UnityWebRequest.Result.Success)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
The documentation from uploadcare looks like this:
APIs causing headaches… It’s like they’re playing a game of “who can make the developers suffer the most”!
Anyway, to answer your questions:
Have you tried using www.downloadHandler.text instead of www.error. It might give you a more detailed message about what went wrong.
As for missing something in your understanding of UnityWebRequest forms and the documentation - well, I’m not sure that’s even possible. The documentation is probably as clear as mud.