How to upload a csv file using gsm 900a module

hi this is Hemant
I am currently working on a project based on esp32 or gsm 900a module
in this project, I want to send my sensor data file (which is store in sd card) to a remote server
can anyone help me
I was successfully send file using esp32(wi-fi).
thanks for help in advance.

Hi

I used iotplotter . Com. This site has some code examples for posting data (csv or json) to help you.

The server is expecting http which you can do in python( MicroPython) or Arduino

If you post your code up I can offer some suggestions

thank you for answer

after lots of search and forms reading i found out this code
but this code work with less then 1kb file
how can i send more then 1kb file
i want to send 1mb file

#include <Arduino.h>

#include <SoftwareSerial.h>
#include <HardwareSerial.h>

#include <Wire.h>
#include "FS.h"
#include "SD.h"
#include <SPI.h>
#define  TINY_GSM_MODEM_SIM900
#define SerialMon Serial
HardwareSerial SerialAT(1);

#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 1200
#endif
#define TINY_GSM_YIELD() { delay(2); }
const char apn[]  = "apn"; 
const char gprsUser[] = "";
const char gprsPass[] = "";
 char server[] ="my.site.in";
const char resource[] = "http://my.site.in/upload_file.php";
const int  port = 80;
unsigned long timeout;

File myFile;
String requestBody;
String tail;
String post_host = "my.site.in";
const int  post_port  = 80;
String  url = "/upload_file.php";



#include <TinyGsmClient.h>
TinyGsm modem(SerialAT);
TinyGsmClient client(modem);
/*
   An example on how to use ESP32 hardware serial with PZEM004T
*/
 #define RXD2 16
 #define TXD2 17
 #define RXD3 32
 #define TXD3 33

//format bytes
String formatBytes(unsigned int bytes) {
  if (bytes < 1024) {
    return String(bytes) + "B";
  } else if (bytes < (1024 * 1024)) {
    return String(bytes / 1024.0) + "KB";
  } else if (bytes < (1024 * 1024 * 1024)) {
    return String(bytes / 1024.0 / 1024.0) + "MB";
  }
}
void readFile(fs::FS &fs, String path) {
  Serial.printf("Reading file: %s\n", path);

  File myFile = fs.open(path);
  if (!myFile) {
    Serial.println("Failed to open file for reading");
    return;
  }
}

void setup()
{  Serial.begin(57600);  
  

  

  Serial.println("Initializing..........");
 
}

 
void loop()
{
 

   Serial.print("Initializing SD card...");
  if (!SD.begin())
  {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  //read file from SD
  //define file
  //myFile = SD.open("/data.wav");
  myFile = SD.open("/code.csv");
  //readFile(SD, "/data.wav");
  readFile(SD, "/code.csv");
  String fileName = myFile.name();
  String fileSize = formatBytes(myFile.size());

  Serial.println();
  Serial.println("file exists");


  if (myFile)
  {
    Serial.println("test file:ok");
    // print content length and host
    Serial.print("contentLength : ");
    Serial.println(fileSize);
    Serial.print("connecting to ");
    Serial.println(post_host);

    // We now create a URI for the request
    Serial.println("Connected to server");
    Serial.print("Requesting URL: ");
    Serial.println(url);

    // Make a HTTP request and add HTTP headers
    //String boundary = "CustomizBoundarye----";
    //change with your content type
    String contentType = "text/csv";//"audio/x-wav";
    String portString = String(post_port);
    String hostString = String(post_host);

String    requestHead = "--RandomNerdTutorials\r\nContent-Disposition: form-data; name=\"data\"; filename=\"code.csv\"\r\nContent-Type: text/csv\r\n\r\n";
    tail = "\r\n--RandomNerdTutorials--\r\n";
  
     int contentLength =  requestHead.length() + myFile.size() + tail.length();
  
  
 
 
 /********************GSM Communication Starts********************/
 
  //..................................................
  SerialAT.begin(115200,SERIAL_8N1,32,33, false);
  delay(600);
  SerialMon.println("Initializing modem...");


  // modem.init();
   
  modem.restart();
  SerialMon.print("Waiting for network...");
  if (!modem.waitForNetwork()) {
    SerialMon.println(" fail");
    delay(1000);
    return;
  }
  SerialMon.println(" success");
  if (modem.isNetworkConnected()) {
    SerialMon.println("Network connected");
  }

  SerialMon.print(F("Connecting to "));
  SerialMon.print(apn);
  if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
    SerialMon.println(" fail");
    delay(1000);
    return;
  }
  SerialMon.println(" success");

  if (modem.isGprsConnected()) {
    SerialMon.println("GPRS connected");
  }

  if (!client.connect(server, port)) {
    SerialMon.println(" fail");
  }
  SerialMon.println("Performing HTTP POST request...");
  client.print(String("POST ") + resource + " HTTP/1.1\r\n");
  client.print(String("Host: ") + server + "\r\n");
  client.println("Content-Length: " + String(contentLength, DEC));
        client.println("Content-Type: multipart/form-data; boundary=RandomNerdTutorials");
        client.println();
        client.print(requestHead );


        client.write(myFile);
        // create file buffer
        const int bufSize = 2048;
        byte clientBuf[bufSize];
        int clientCount = 0;
    
        while (myFile.available())
        {
          clientBuf [clientCount] = myFile.read ();
          clientCount++;
          if (clientCount > (bufSize - 1))
          {
            client.write((const uint8_t *)clientBuf, bufSize);
            clientCount = 0;
          }
    
        }
    
        if (clientCount > 0)
        {
          client.write((const uint8_t *)clientBuf, clientCount);
    
        }
    
        // send tail
        //      char charBuf3[tail.length() + 1];
        //      tail.toCharArray(charBuf3, tail.length() + 1);
        client.print(tail);
    
    
        //Serial.print(charBuf3);
      }
      else
      {
        // if the file didn't open, print an error:
        Serial.println("error opening test.WAV");
        Serial.println("Post Failure");
      }
    
    
    
      // Read all the lines of the reply from server and print them to Serial
    
    
      Serial.println("request sent");


  timeout = millis();
  while (client.connected() && millis() - timeout < 10000L) {
    while (client.available()) {
      char c = client.read();
      SerialMon.print(c);
      timeout = millis();
    }
  }
  SerialMon.println();
  client.stop();
  SerialMon.println(F("Server disconnected"));
  modem.gprsDisconnect();
  SerialMon.println(F("GPRS disconnected"));



  
}