Skip to content

Commit a6071f6

Browse files
committed
Fix file operation and download URL issue #291
1 parent aa3472d commit a6071f6

File tree

17 files changed

+486
-203
lines changed

17 files changed

+486
-203
lines changed

examples/CloudStorage/Download/Download.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See examples/App/AppInitialization for more authentication examples.
66
*
77
* The OAuth2.0 authentication or access token authorization is required for Cloud Storage operations.
8-
*
8+
*
99
* For Google JSON API reference documentation, please visit
1010
* https://cloud.google.com/storage/docs/json_api/v1/objects/get
1111
*
@@ -108,14 +108,14 @@ void loop()
108108
cstorage.download(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options, processData, "⬇️ downloadTask");
109109

110110
// Async call with AsyncResult for returning result.
111-
cstorage.download(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options, cloudStorageResult);
111+
// cstorage.download(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options, cloudStorageResult);
112112

113113
// Sync call which waits until the operation complete.
114-
bool status = cstorage.download(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options);
115-
if (status)
116-
Serial.println("🔽 Dowload task (await), complete!✅️");
117-
else
118-
Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
114+
// bool status = cstorage.download(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options);
115+
// if (status)
116+
// Serial.println("🔽 Dowload task (await), complete!✅️");
117+
// else
118+
// Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
119119

120120
#endif
121121
}

examples/CloudStorage/Upload/Upload.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See examples/App/AppInitialization for more authentication examples.
66
*
77
* The OAuth2.0 authentication or access token authorization is required for Cloud Storage operations.
8-
*
8+
*
99
* For Google JSON API reference documentation, please visit
1010
* https://cloud.google.com/storage/docs/json_api/v1/objects/insert
1111
* https://cloud.google.com/storage/docs/resumable-uploads
@@ -113,14 +113,14 @@ void loop()
113113
cstorage.upload(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options, processData, "⬆️ uploadTask");
114114

115115
// Async call with AsyncResult for returning result.
116-
cstorage.upload(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options, cloudStorageResult);
116+
// cstorage.upload(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options, cloudStorageResult);
117117

118118
// Sync call which waits until the operation complete.
119-
bool status = cstorage.upload(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options);
120-
if (status)
121-
Serial.println("🔼 Upload task(await), complete!✅️");
122-
else
123-
Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
119+
// bool status = cstorage.upload(aClient, GoogleCloudStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), options);
120+
// if (status)
121+
// Serial.println("🔼 Upload task(await), complete!✅️");
122+
// else
123+
// Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
124124
#endif
125125
}
126126

examples/FirestoreDatabase/Documents/CreateDocument/CreateDocument.ino

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ void loop()
9595
// e.g. "collection/document/subcollection", the document with autogenerated ID will be created
9696
// e.g. "collection/document/subcollection/bvOHWMu8xTOrO8aeGk9h"
9797

98-
// There are some restrictions about the document ID and API endpoints which you have to know
99-
// when working with this library.
100-
101-
// 1. Document ID Restrictions
98+
// Document ID Restrictions
10299
//////////////////////////////
103100

104101
// The document ID must consist of valid UTF-8 characters with 1,500 bytes maximum.
@@ -114,14 +111,6 @@ void loop()
114111
// In the console, you can create the ancestor document "test_doc_creation/doc_1" before running this example
115112
// to avoid non-existent ancestor documents case.
116113

117-
// 2. REST API restrictions
118-
///////////////////////////
119-
120-
// As mentioned above, the document path will be used as the path parameter and
121-
// query parameter of the REST API endpoint (URL).
122-
// To ensures that the information is transmitted accurately and without corruption, the
123-
// document path that contains some special characters should be URL-encoded.
124-
125114
// For the Firestore data model, plesae see https://firebase.google.com/docs/firestore/data-model
126115

127116
// We will create the documents in the path "test_doc_creation/doc_1/col_1/data_?"

examples/Messaging/WebClient/fcm.html

Lines changed: 223 additions & 121 deletions
Large diffs are not rendered by default.

examples/RealtimeDatabase/StreamPerformanceTest/index.html

Lines changed: 200 additions & 22 deletions
Large diffs are not rendered by default.

examples/Storage/Download/Download.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ void loop()
9999
// storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4", "access token"), getFile(media_file), processData, "downloadTask");
100100

101101
// Async call with AsyncResult for returning result.
102-
storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), storageResult);
102+
// storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), storageResult);
103103

104104
// Sync call which waits until the operation complete.
105-
bool status = storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file));
106-
if (status)
107-
Serial.println("🔽 Dowload task (await), complete!✅️");
108-
else
109-
Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
105+
// bool status = storage.download(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file));
106+
// if (status)
107+
// Serial.println("🔽 Dowload task (await), complete!✅️");
108+
// else
109+
// Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
110110
#endif
111111
}
112112

examples/Storage/Upload/Upload.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ void loop()
9797
storage.upload(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), "video/mp4", processData, "⬆️ uploadTask");
9898

9999
// Async call with AsyncResult for returning result.
100-
storage.upload(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), "video/mp4", storageResult);
100+
// storage.upload(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), "video/mp4", storageResult);
101101

102102
// Sync call which waits until the operation complete.
103-
bool status = storage.upload(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), "video/mp4");
104-
if (status)
105-
Serial.println("🔼 Upload task(await), complete!✅️");
106-
else
107-
Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
103+
// bool status = storage.upload(aClient, FirebaseStorage::Parent(STORAGE_BUCKET_ID, "media.mp4"), getFile(media_file), "video/mp4");
104+
// if (status)
105+
// Serial.println("🔼 Upload task(await), complete!✅️");
106+
// else
107+
// Firebase.printf("Error, msg: %s, code: %d\n", aClient.lastError().message().c_str(), aClient.lastError().code());
108108
#endif
109109
}
110110

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "FirebaseClient",
3-
"version": "2.1.8",
3+
"version": "2.1.9",
44
"keywords": "communication, REST, esp32, esp8266, arduino",
55
"description": "Async Firebase Client library for Arduino.",
66
"repository": {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name=FirebaseClient
22

3-
version=2.1.8
3+
version=2.1.9
44

55
author=Mobizt
66

src/core/AsyncClient/AsyncClient.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ class AsyncClientClass PUBLIC_DATABASE_RESULT_IMPL_BASE
590590
sData->response.val[resns::payload] += (char *)temp;
591591
mem.release(&temp);
592592
}
593-
594-
// gzip header + trailer length
593+
594+
// gzip header + trailer length
595595
if (res == -1 && sData->response.flags.gzip && sData->response.chunkInfo.dataPos <= 15)
596596
res = 0;
597597

@@ -833,7 +833,9 @@ class AsyncClientClass PUBLIC_DATABASE_RESULT_IMPL_BASE
833833
// It should set in readPayload when decodeChunks returns -1.
834834
if (!sData->response.flags.chunks)
835835
sData->response.flags.payload_remaining = false;
836+
836837
#if defined(ENABLE_FS)
838+
// Close file when uploading response complete.
837839
sData->request.closeFile();
838840
#endif
839841

@@ -1005,7 +1007,6 @@ class AsyncClientClass PUBLIC_DATABASE_RESULT_IMPL_BASE
10051007
clear(sData->request.val[reqns::header]);
10061008
sData->request.addRequestHeader(method, path, extras);
10071009
sData->request.addHostHeader(sData->request.getHost(true, &sData->response.val[resns::location]).c_str());
1008-
10091010
sData->auth_used = options.auth_used;
10101011

10111012
if (!options.auth_used)

0 commit comments

Comments
 (0)