String head = "--PotWatcher\r\nContent-Disposition: form-data; name=\"image\"; filename=\"PotWatcherImage.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
String tail = "\r\n--PotWatcher--\r\n";
// Make a HTTP GET request:
Serial.println("Performing HTTP POST request...");
client.print(String("POST ") + resource + " HTTP/1.1\r\n");
client.print(String("Host: ") + host + "\r\n");
client.print(String("Authorization: ") + uuid + "\r\n");
client.println("Connection: Keep-Alive");
client.println("Content-Length: " + String(length));
client.println("Content-Type: multipart/form-data;boundary=PotWatcher");
client.println();
client.print(head);
uint8_t *fbBuf = payload;
for (size_t n = 0; n < length; n = n + PACKET_SIZE)
{
if (n + PACKET_SIZE < length)
{
client.write(fbBuf, PACKET_SIZE);
fbBuf += PACKET_SIZE;
}
else if (length % PACKET_SIZE > 0)
{
size_t remainder = length % PACKET_SIZE;
client.write(fbBuf, remainder);
}
}
client.print(tail);
String head = "--PotWatcher\r\nContent-Disposition: form-data; name=\"image\"; filename=\"PotWatcherImage.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
String tail = "\r\n--PotWatcher--\r\n";
// Make a HTTP GET request:
Serial.println("Performing HTTP POST request...");
client.print(String("POST ") + resource + " HTTP/1.1\r\n");
client.print(String("Host: ") + host + "\r\n");
client.print(String("Authorization: ") + uuid + "\r\n");
client.println("Connection: Keep-Alive");
client.println("Content-Length: " + String(length));
client.println("Content-Type: multipart/form-data;boundary=PotWatcher");
client.println();
client.print(head);
uint8_t *fbBuf = payload;
for (size_t n = 0; n < length; n = n + PACKET_SIZE)
{
if (n + PACKET_SIZE < length)
{
client.write(fbBuf, PACKET_SIZE);
fbBuf += PACKET_SIZE;
}
else if (length % PACKET_SIZE > 0)
{
size_t remainder = length % PACKET_SIZE;
client.write(fbBuf, remainder);
}
}
client.print(tail);