Skip to content

Commit

Permalink
Fix BLOB upload issue in Firebase Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jul 27, 2024
1 parent 0bd66fb commit e1f31bf
Show file tree
Hide file tree
Showing 29 changed files with 375 additions and 526 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github)

![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.3.7-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.3.8-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)

[![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)

Revision `2024-07-26T08:35:39Z`
Revision `2024-07-27T09:57:58Z`

## Table of Contents

Expand Down Expand Up @@ -1260,28 +1260,34 @@ In case of file errors, you have to verify your hardware and your code to make s

```cpp

#include <FS.h>
File myFile; // Define the File object globally.

#define MY_FS SPIFFS

void fileCallback(File &file, const char *filename, file_operating_mode mode)
{
// FILE_OPEN_MODE_READ, FILE_OPEN_MODE_WRITE and FILE_OPEN_MODE_APPEND are defined in this library
// MY_FS is defined in this example
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}

FileConfig media_file("/media.mp4", fileCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@
#include <WiFi.h>
#endif

#include <FirebaseClient.h>
// In ESP32 Core SDK v3.x.x, to use filesystem in this library,
// the File object should be defined globally
// and the library's internal defined FS object should be set with
// this global FS object in fileCallback function.
#include <FS.h>
File myFile;

#if defined(ENABLE_FS) // Defined in this library
#if defined(FLASH_SUPPORTS) // Defined in this library
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#define MY_FS SPIFFS
#else
#include <SPI.h>
#include <SD.h>
#define MY_FS SD
#endif
#endif

#include <FirebaseClient.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
Expand Down Expand Up @@ -228,19 +227,21 @@ void fileCallback(File &file, const char *filename, file_operating_mode mode)
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@
#include <WiFi.h>
#endif

#include <FirebaseClient.h>
// In ESP32 Core SDK v3.x.x, to use filesystem in this library,
// the File object should be defined globally
// and the library's internal defined FS object should be set with
// this global FS object in fileCallback function.
#include <FS.h>
File myFile;

#if defined(ENABLE_FS) // Defined in this library
#if defined(FLASH_SUPPORTS) // Defined in this library
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#define MY_FS SPIFFS
#else
#include <SPI.h>
#include <SD.h>
#define MY_FS SD
#endif
#endif

#include <FirebaseClient.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
Expand Down Expand Up @@ -219,19 +218,21 @@ void fileCallback(File &file, const char *filename, file_operating_mode mode)
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@
#include <WiFi.h>
#endif

#include <FirebaseClient.h>
// In ESP32 Core SDK v3.x.x, to use filesystem in this library,
// the File object should be defined globally
// and the library's internal defined FS object should be set with
// this global FS object in fileCallback function.
#include <FS.h>
File myFile;

#if defined(ENABLE_FS) // Defined in this library
#if defined(FLASH_SUPPORTS) // Defined in this library
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#define MY_FS SPIFFS
#else
#include <SPI.h>
#include <SD.h>
#define MY_FS SD
#endif
#endif

#include <FirebaseClient.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
Expand Down Expand Up @@ -222,19 +221,21 @@ void fileCallback(File &file, const char *filename, file_operating_mode mode)
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@
#include <WiFi.h>
#endif

#include <FirebaseClient.h>
// In ESP32 Core SDK v3.x.x, to use filesystem in this library,
// the File object should be defined globally
// and the library's internal defined FS object should be set with
// this global FS object in fileCallback function.
#include <FS.h>
File myFile;

#if defined(ENABLE_FS) // Defined in this library
#if defined(FLASH_SUPPORTS) // Defined in this library
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#define MY_FS SPIFFS
#else
#include <SPI.h>
#include <SD.h>
#define MY_FS SD
#endif
#endif

#include <FirebaseClient.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
Expand Down Expand Up @@ -213,19 +212,21 @@ void fileCallback(File &file, const char *filename, file_operating_mode mode)
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@
#include <WiFi.h>
#endif

#include <FirebaseClient.h>
// In ESP32 Core SDK v3.x.x, to use filesystem in this library,
// the File object should be defined globally
// and the library's internal defined FS object should be set with
// this global FS object in fileCallback function.
#include <FS.h>
File myFile;

#if defined(ENABLE_FS) // Defined in this library
#if defined(FLASH_SUPPORTS) // Defined in this library
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#define MY_FS SPIFFS
#else
#include <SPI.h>
#include <SD.h>
#define MY_FS SD
#endif
#endif

#include <FirebaseClient.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
Expand Down Expand Up @@ -229,19 +228,21 @@ void fileCallback(File &file, const char *filename, file_operating_mode mode)
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@
#include <WiFi.h>
#endif

#include <FirebaseClient.h>
// In ESP32 Core SDK v3.x.x, to use filesystem in this library,
// the File object should be defined globally
// and the library's internal defined FS object should be set with
// this global FS object in fileCallback function.
#include <FS.h>
File myFile;

#if defined(ENABLE_FS) // Defined in this library
#if defined(FLASH_SUPPORTS) // Defined in this library
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#define MY_FS SPIFFS
#else
#include <SPI.h>
#include <SD.h>
#define MY_FS SD
#endif
#endif

#include <FirebaseClient.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
Expand Down Expand Up @@ -220,19 +219,21 @@ void fileCallback(File &file, const char *filename, file_operating_mode mode)
switch (mode)
{
case file_mode_open_read:
file = MY_FS.open(filename, FILE_OPEN_MODE_READ);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_READ);
break;
case file_mode_open_write:
file = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_WRITE);
break;
case file_mode_open_append:
file = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
myFile = MY_FS.open(filename, FILE_OPEN_MODE_APPEND);
break;
case file_mode_remove:
MY_FS.remove(filename);
break;
default:
break;
}
// Set the internal FS object with global File object.
file = myFile;
}
#endif
Loading

0 comments on commit e1f31bf

Please sign in to comment.