这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

help - how to efficiently send files from spiffs #171

@biancoblu79

Description

@biancoblu79

Hello,

I am using google-cloud-iot-arduino on an ESP8266 based board. I am trying to send files to Google Cloud and I am currently able to do it by splitting them in 256 byte chunks. I store these chunks in Firestore using a cloud function and then put them back together using another cloud function and I store the file in a GCS bucket. What is the best way for me to use publishTelemetry to send an entire file (avg file size is 40k)? thanks! Marco .. here below what I am currently doing

size_t size = 0;
File dataFile = SPIFFS.open(pic_file_camera, "r");
size = dataFile.size();

if (dataFile) {
byte data[256];

int i = 0;
int total_bytes = 0;
while (dataFile.available()) {
  if (i < 256) {
    // if we haven't read 256 bytes yet, then keep reading!
    data[i++] = dataFile.read();
    total_bytes ++;
  } else {
    delay(100);
    //  send the read 256 bytes and reset the counter
    publishTelemetry("/pictures", (char *)data, 256);
    i = 0;
  }
}

// send the remaining i bytes 
delay(100);
publishTelemetry((char *)data, i);

delay(20);
// Close the file
dataFile.close();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions