Upload File From camera with HTTP REQUEST post method

Hello there,
I am new to appgyver, after doing some tutorial, I’ve started my first project.
I am trying to create a very simple app that take a picture from the camera (this is was very easy and working) and send it to a local server where they will be processed for the purpose.
The image captured into the APP is stored into an app variable.
I’ve created a button with a tap logic that takes to an HTTP Request.
The server is listening on a local network, not on internet !
so the request address is: http://192.168.43.23/upload.php

the script, on server side is expecting two elements.
image
name

I’ve obviously test with postman POST: 192.168.43.23/upload.php?image&name
the image is enveloped inside the body as an image/jpg or png type.

I’ve also put a TOAST that must capture the answer from local server, but nothing seems to happen.

I am start thinking that a local server can’t be reached… just public servers.

Thank you
Massimo

Hi,
You are right, Composer cannot make requests to a local servers as it is running externally from your network!

Hello, there is an update.
I am using this javascript logic:

const { image, upload, path, filename } = inputs;
const url = ‘https://xxxxxxx-db-it-01.xxxx.us/upload(2).php’;
const formData = new FormData();
const file = {
uri: image.path,
name: filename,
size: image.size,
type: ‘image/jpg’,
};

formData.append(‘image’, file);
formData.append(‘update’, “”);

const response = await fetch(url, {
method: ‘POST’,
headers: {
//Accept: “application/json”,
‘Content-Type’: ‘multipart/form-data’,
//upload’: upload,
},

body: formData,
});

{
return { result: response };
}


Server side I can share this curl syntax code snippet that let you understand better how server is expecting the file:

curl --location --request POST ‘https://xxxxxx-db-it-01.xxxx.us/upload(2).php
–form ‘file=@"/Users/massimo/Pictures/my tattoo.png"’
–form ‘upload=""’


I receive an answer from the server, I can Intercept the response into an Alert component


The attached image let you understand the inputs. Image is stored into an AppVariable called ImageFromCamera


I suppose is a Javascript syntax issue, but is seems to be ok.

Anybody can help me, I am stuck on this.