sd card directory name

how can i find out the sd card file path name?
I am trying to do a POST request to send images to my webserver using the SIM7000 LTE SHIELD. and for that post request, it requires to add the path name of the image. My images are stored in the sd card. What is the path name to that location?

That's a different path. If you send a POST request to a resource on a web server you address the resource using a URL. The first part of that URL is the scheme (the used protocol), followed by the hostname and optionally port number. The part after that is called the path name. Most probably you need to specify this and not a path to an SD card file.

pylon:
That's a different path. If you send a POST request to a resource on a web server you address the resource using a URL. The first part of that URL is the scheme (the used protocol), followed by the hostname and optionally port number. The part after that is called the path name. Most probably you need to specify this and not a path to an SD card file.

Well the path name is the location where the file is stored right? so if the file is stored in the SD card, wouldnt that be the path for the POST request?

exampe code for the POST request:

sprintf(body, "{\"lat\":%s,\"long\":%s}\r\n", latBuff, longBuff); 
    sprintf(URL, "POST /dweet/for/%s HTTP/1.1\r\nHost: dweet.io\r\nContent-Length: %i\r\n\r\n", imei, strlen(body));

    while (counter < 3 && !fona.postData("www.dweet.io", 443, "HTTPS", URL, body)) { // Server, port, connection type, URL
      Serial.println(F("Failed to complete HTTP/HTTPS request..."));
      counter++; // Increment counter
      delay(1000);
    }

A request is send to the server to request a certain ressource at a certain path on the server. If you are posting data to the server the path in the http header is the path to the upload script that handles the data.

Well the path name is the location where the file is stored right? so if the file is stored in the SD card, wouldnt that be the path for the POST request?

No, for the POST request it's the path on the server. For simple files this is the storage path of the file on the server but for POST requests it's a virtual path in most cases.

In your example the path name is "/dweet/for/", which most probably is not the storage path of an existing file but only a virtual path so the server knows which server side program is to be called. In this example no SD card file is involved.

pylon:
No, for the POST request it's the path on the server. For simple files this is the storage path of the file on the server but for POST requests it's a virtual path in most cases.

What you mean is a PUT request. When POSTing data to a server it will always be handled by a script. See the HTTP/1.1 standard. If you provide a url, e.g. /myserver/files/data.txt, and the file is not present on the server you will get a "ressource not found" answer.

What you mean is a PUT request. When POSTing data to a server it will always be handled by a script.

Bullshit. If you follow the HTTP standard closely, POST is used to create a resource while PUT is used to update it (often referred as a REST interface). But I cannot find any reference in the standard that dictates POST request have to be handled by a script.

If you provide a url, e.g. /myserver/files/data.txt, and the file is not present on the server you will get a "ressource not found" answer.

Excuse me but this is also not the complete truth. It's up to the server which paths it treats as direct references to existing files and which are only virtual paths where the complete request is handled by a server side program.

@OP: Please ignore the answers of LightuC, they are not related to your problem and may only confuse you more.
Please describe what you're trying to achieve and not how you tried that in the past. Post the URL where you try to send the images. Did you write the server side code yourself or is that code developed by someone else (maybe public service)?

pylon:
Bullshit. If you follow the HTTP standard closely, POST is used to create a resource while PUT is used to update it (often referred as a REST interface). But I cannot find any reference in the standard that dictates POST request have to be handled by a script.

Wow, what a nice and friendly answer. Then I might cite from the standard:

RFC7231:
The POST method requests that the target resource process the
representation enclosed in the request according to the resource's
own specific semantics. For example, POST is used for the following
functions (among others):

o Providing a block of data, such as the fields entered into an HTML
form, to a data-handling process;

Which is exactly what he wants to do.

pylon:
Excuse me but this is also not the complete truth. It's up to the server which paths it treats as direct references to existing files and which are only virtual paths where the complete request is handled by a server side program.

Agreed, but most probably irrelevant for the OP.

pylon:
@OP: Please ignore the answers of LightuC, they are not related to your problem and may only confuse you more.
Please describe what you're trying to achieve and not how you tried that in the past. Post the URL where you try to send the images. Did you write the server side code yourself or is that code developed by someone else (maybe public service)?

arduino -> LTE shield -> POST request -> Webserver, as far as I understand his/her original post. In that case he/she probably should not ignore my answer, because it will lead him/her to the correct code.

Ok so here is the deal. With whatever limited knowledge i have, i agree with LightuC.
The POST request is made to send the information from one point to the other. This is not FTP protocol where you have to send data to a location or folder.
With POST, you describe the information within your body and URL, and send it to your server, your server replies back with a 200 OK and insures that the packet has been received.
So the location i am looking for is the location for the SD card file and not the file located on the server.

I use POSTMAN very frequently to find out how a raw request is made. either POST or GET. So i tried duplicating the same task that i want my arduino to do, and here is the request made for which i received a 200 OK. and confirmed on my server that the file was received and saved.

Please advice?

forum.png

ammarqs:
So the location i am looking for is the location for the SD card file and not the file located on the server.

Not quite. If what you want to do is to send a file from an sd-card from the arduino over your shield to the webserver, you need to put in the receiving url, e.g. imgupload.php or whatever your webserver uses to store the image.

Like this:

w3schools.com:
POST /test/demo_form.php HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2

Here is how you do it: You send the header to the server, followed by \r\n\r\n. Then you write your image data to the server. That should give you the 200 OK response.

Yes thats exactly what i am doing. We have a process.php file on our server that takes in data and saves it to the database. I already have that part implemented where i send string data to the webserver and it stores it to the database.

So as you mentioned about image data, so that the image data in actual raw format? So i read the sd card file to a variable and have that variable attached to my POST script?

Yes, and your process.php will have to put that data into a file on the server.

Yes that part is done. If you refer to the picture i posted using postman, i already tested that part first to make sure that my server is taking in images and storing it. Now i have to try pulling out a picture from the sd card and post it.

what data type is the file i am reading? I tried the char * but i dont think this is correct. it does copy the image file to that variable, but i am certain this is not the right way.

  // open the file for reading:
  myFile = SD.open("1.JPG");
  if (myFile) {
    Serial.println("1.JPG:");
 
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      char * testvariable = myFile.read();
      Serial.write(testvariable);
      
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening 1.JPG");
  }