-->
Page 2 of 5

Re: SPIFFS file read and write example

PostPosted: Sun Apr 03, 2016 3:44 pm
by picstart
First post above may suffer from the typical hidden dependency issue that Arduino code unfortunately all to often has.
Here is the error
In file included from dk_SPIFFS.ino.ino:7:0:
C:\Users\Doug\AppData\Local\Temp\build4710410840931580516.tmp\FS.h:62:12: error: 'size_t fs::File::readBytes(char*, size_t)' marked override, but does not override
size_t readBytes(char *buffer, size_t length) override {
^
Error compiling.

Re: SPIFFS file read and write example

PostPosted: Thu Aug 11, 2016 7:06 pm
by Farhan Younus
I have found an easy way to read all the content in a SPIFF file. Here's an example.

Code: Select allFile f = SPIFFS.open( "/your-file-name.txt, "r");
  if (!f) {
    Serial.println("file open failed");
  }
  String data = f.readString();
  Serial.println("------ Loop Read method -------");
  Serial.println(data);
  f.close();


the file name extension can be any type with data type text/html, text/plain, etc...

Re: SPIFFS file read and write example

PostPosted: Mon Sep 26, 2016 7:03 pm
by RichardS
Would this not terminate the read when it hits a zero? Not a character '0' but a byte of 0x00.

RichardS

Re: SPIFFS file read and write example

PostPosted: Sun Dec 25, 2016 10:58 pm
by nopnop2002
Thank you for your useful example.
There is no f.close() for reading