Skip to content

Commit

Permalink
Fix Google Cloud Storage Resumable/Multipart BLOB upload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jul 26, 2024
1 parent d99701a commit 0bd66fb
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 47 deletions.
4 changes: 2 additions & 2 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.6-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.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 Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)

Revision `2024-07-25T04:03:36Z`
Revision `2024-07-26T08:35:39Z`

## Table of Contents

Expand Down
4 changes: 2 additions & 2 deletions examples/CloudStorage/Async/Callback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Downloaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.downloadInfo().progress, "%", aResult.downloadInfo().downloaded, aResult.downloadInfo().total);
if (aResult.downloadInfo().total == aResult.downloadInfo().downloaded)
{
Firebase.printf("Download task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Download task: %s, completed!\n", aResult.uid().c_str());
}
}

Expand All @@ -241,7 +241,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Uploaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.uploadInfo().progress, "%", aResult.uploadInfo().uploaded, aResult.uploadInfo().total);
if (aResult.uploadInfo().total == aResult.uploadInfo().uploaded)
{
Firebase.printf("Upload task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Upload task: %s, completed!\n", aResult.uid().c_str());
Serial.print("Download URL: ");
Serial.println(aResult.uploadInfo().downloadUrl);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/CloudStorage/Async/Callback/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void loop()
Serial.println("Upload file...");

GoogleCloudStorage::uploadOptions options;
options.mime = "media.mp4";
options.mime = "video/mp4";
options.uploadType = GoogleCloudStorage::upload_type_resumable;
// options.uploadType = GoogleCloudStorage::upload_type_simple;
// options.uploadType = GoogleCloudStorage::upload_type_multipart;
Expand Down Expand Up @@ -235,7 +235,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Downloaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.downloadInfo().progress, "%", aResult.downloadInfo().downloaded, aResult.downloadInfo().total);
if (aResult.downloadInfo().total == aResult.downloadInfo().downloaded)
{
Firebase.printf("Download task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Download task: %s, completed!\n", aResult.uid().c_str());
}
}

Expand All @@ -244,7 +244,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Uploaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.uploadInfo().progress, "%", aResult.uploadInfo().uploaded, aResult.uploadInfo().total);
if (aResult.uploadInfo().total == aResult.uploadInfo().uploaded)
{
Firebase.printf("Upload task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Upload task: %s, completed!\n", aResult.uid().c_str());
Serial.print("Download URL: ");
Serial.println(aResult.uploadInfo().downloadUrl);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/CloudStorage/Async/NoCallback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Downloaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.downloadInfo().progress, "%", aResult.downloadInfo().downloaded, aResult.downloadInfo().total);
if (aResult.downloadInfo().total == aResult.downloadInfo().downloaded)
{
Firebase.printf("Download task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Download task: %s, completed!\n", aResult.uid().c_str());
}
}

Expand All @@ -234,7 +234,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Uploaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.uploadInfo().progress, "%", aResult.uploadInfo().uploaded, aResult.uploadInfo().total);
if (aResult.uploadInfo().total == aResult.uploadInfo().uploaded)
{
Firebase.printf("Upload task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Upload task: %s, completed!\n", aResult.uid().c_str());
Serial.print("Download URL: ");
Serial.println(aResult.uploadInfo().downloadUrl);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/CloudStorage/Async/NoCallback/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void loop()
Serial.println("Upload file...");

GoogleCloudStorage::uploadOptions options;
options.mime = "media.mp4";
options.mime = "video/mp4";
options.uploadType = GoogleCloudStorage::upload_type_resumable;
// options.uploadType = GoogleCloudStorage::upload_type_simple;
// options.uploadType = GoogleCloudStorage::upload_type_multipart;
Expand Down Expand Up @@ -228,7 +228,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Downloaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.downloadInfo().progress, "%", aResult.downloadInfo().downloaded, aResult.downloadInfo().total);
if (aResult.downloadInfo().total == aResult.downloadInfo().downloaded)
{
Firebase.printf("Download task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Download task: %s, completed!n", aResult.uid().c_str());
}
}

Expand All @@ -237,7 +237,7 @@ void printResult(AsyncResult &aResult)
Firebase.printf("Uploaded, task: %s, %d%s (%d of %d)\n", aResult.uid().c_str(), aResult.uploadInfo().progress, "%", aResult.uploadInfo().uploaded, aResult.uploadInfo().total);
if (aResult.uploadInfo().total == aResult.uploadInfo().uploaded)
{
Firebase.printf("Upload task: %s, completed!", aResult.uid().c_str());
Firebase.printf("Upload task: %s, completed!\n", aResult.uid().c_str());
Serial.print("Download URL: ");
Serial.println(aResult.uploadInfo().downloadUrl);
}
Expand Down
6 changes: 5 additions & 1 deletion examples/Storage/Async/Callback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
* Storage::download(<AsyncClient>, <FirebaseStorage::Parent>, <file_config_data>, <AsyncResultCallback>, <uid>);
*
* <AsyncClient> - The async client.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id and object in its constructor.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id, object and/or access token in its constructor.
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object.
* <AsyncResultCallback> - The async result callback (AsyncResultCallback).
* <uid> - The user specified UID of async result (optional).
*
* The bucketid is the Storage bucket Id of object to download.
* The object is the object in Storage bucket to download.
* The access token is the Firebase Storage's file access token which used only for priviledge file download access in non-authentication mode (NoAuth).
*
* The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient
*/
Expand Down Expand Up @@ -162,6 +163,9 @@ void loop()

#if defined(ENABLE_FS)
storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), asyncCB, "downloadTask");
// You can provide the access token in case non-authentication mode (NoAuth) for priviledge access file download.
// storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4", "access token"), getFile(media_file), asyncCB, "downloadTask");

#endif
}
}
Expand Down
5 changes: 4 additions & 1 deletion examples/Storage/Async/Callback/OTA/OTA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
* Storage::ota(<AsyncClient>, <FirebaseStorage::Parent>, <AsyncResultCallback>, <uid>);
*
* <AsyncClient> - The async client.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id and object in its constructor.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id, object and/or access token in its constructor.
* <AsyncResultCallback> - The async result callback (AsyncResultCallback).
* <uid> - The user specified UID of async result (optional).
*
* The bucketid is the Storage bucket Id of object to download.
* The object is the object in Storage bucket to download.
* The access token is the Firebase Storage's file access token which used only for priviledge file download access in non-authentication mode (NoAuth).
*
* The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient
*/
Expand Down Expand Up @@ -136,6 +137,8 @@ void loop()
#endif

storage.ota(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "firmware.bin"), asyncCB, "otaTask");
// You can provide the access token in case non-authentication mode (NoAuth) for priviledge access file download.
// storage.ota(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "firmware.bin", "access token"), asyncCB, "otaTask");
}
}

Expand Down
5 changes: 4 additions & 1 deletion examples/Storage/Async/NoCallback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
* Storage::download(<AsyncClient>, <FirebaseStorage::Parent>, <file_config_data>, <AsyncResult>);
*
* <AsyncClient> - The async client.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id and object in its constructor.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id, object and/or access token in its constructor.
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object.
* <AsyncResult> - The async result (AsyncResult).
*
* The bucketid is the Storage bucket Id of object to download.
* The object is the object in Storage bucket to download.
* The access token is the Firebase Storage's file access token which used only for priviledge file download access in non-authentication mode (NoAuth).
*
* The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient
*/
Expand Down Expand Up @@ -161,6 +162,8 @@ void loop()

#if defined(ENABLE_FS)
storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), aResult_no_callback);
// You can provide the access token in case non-authentication mode (NoAuth) for priviledge access file download.
// storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4", "access token"), getFile(media_file), aResult_no_callback);
#endif
}

Expand Down
5 changes: 4 additions & 1 deletion examples/Storage/Async/NoCallback/OTA/OTA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* Storage::ota(<AsyncClient>, <FirebaseStorage::Parent>, <AsyncResult>);
*
* <AsyncClient> - The async client.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id and object in its constructor.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id, object and/or access token in its constructor.
* <AsyncResult> - The async result (AsyncResult).
*
* The bucketid is the Storage bucket Id of object to download.
* The object is the object in Storage bucket to download.
* The access token is the Firebase Storage's file access token which used only for priviledge file download access in non-authentication mode (NoAuth).
*
* The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient
*/
Expand Down Expand Up @@ -135,6 +136,8 @@ void loop()
#endif

storage.ota(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "firmware.bin"), aResult_no_callback);
// You can provide the access token in case non-authentication mode (NoAuth) for priviledge access file download.
// storage.ota(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "firmware.bin", "access token"), aResult_no_callback);
}

printResult(aResult_no_callback);
Expand Down
5 changes: 4 additions & 1 deletion examples/Storage/Sync/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
* bool Storage::download(<AsyncClient>, <FirebaseStorage::Parent>, <file_config_data>);
*
* <AsyncClient> - The async client.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id and object in its constructor.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id, object and/or access token in its constructor.
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object.
*
* The bucketid is the Storage bucket Id of object to download.
* The object is the object in Storage bucket to download.
* The access token is the Firebase Storage's file access token which used only for priviledge file download access in non-authentication mode (NoAuth).
*
* This function returns bool status when task is complete.
*
Expand Down Expand Up @@ -172,6 +173,8 @@ void loop()
// There is no download progress available for sync download.
// To get the download progress, use async download instead.
bool result = storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file));
// You can provide the access token in case non-authentication mode (NoAuth) for priviledge access file download.
// bool result = storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4", "access token"), getFile(media_file));

if (result)
Serial.println("Object downloaded.");
Expand Down
7 changes: 5 additions & 2 deletions examples/Storage/Sync/OTA/OTA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* bool Storage::ota(<AsyncClient>, <FirebaseStorage::Parent>);
*
* <AsyncClient> - The async client.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id and object in its constructor.
* <FirebaseStorage::Parent> - The FirebaseStorage::Parent object included Storage bucket Id, object and/or access token in its constructor.
*
* The bucketid is the Storage bucket Id of object to download.
* The object is the object in Storage bucket to download.
* The access token is the Firebase Storage's file access token which used only for priviledge file download access in non-authentication mode (NoAuth).
*
* This function returns bool status when task is complete.
*
Expand All @@ -34,7 +35,7 @@

// For Arduino SAMD21 OTA supports.
// See https://github.com/mobizt/FirebaseClient#ota-update.
#if defined(ARDUINO_ARCH_SAMD)
#if defined(ARDUINO_ARCH_SAMD)
#include <Internal_Storage_OTA.h>
#define OTA_STORAGE InternalStorage
#endif
Expand Down Expand Up @@ -146,6 +147,8 @@ void loop()
// To get the OTA download progress, use async OTA download instead.

bool result = storage.ota(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "firmware.bin"));
// You can provide the access token in case non-authentication mode (NoAuth) for priviledge access file download.
// bool result = storage.ota(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "firmware.bin", "access token"));

if (result)
restart();
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FirebaseClient",
"version": "1.3.6",
"version": "1.3.7",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Async Firebase Client library for Arduino.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.3.6
version=1.3.7

author=Mobizt

Expand Down
Loading

0 comments on commit 0bd66fb

Please sign in to comment.