I've tried the File Upload program to upload files stored on the SD Card to Firebase Storage and it worked fine. then due to a datalogger need, I created a dynamic file naming system function based on month-day on RTC. then the format of the file name is created in a string. when I try again it causes an error in the upload process when I create an upload function like this. When FileName variable used as localFileName and remoteFilename in the upload function, which required const char*, need to call c_str() function from String class. FileName.c_str()need help with this, How to call the String FileName that i had created and write it for syntax?
DateTime now = rtc.now();
FileName[0] = now.day()/10 + '0';
FileName[1] = now.day()%10 + '0';
dayupg=now.day();
FileName[2] = now.month()/10 + '0';
FileName[3] = now.month()%10 + '0';
monthupg=now.month();
FileName[4] = (now.year()/10)%10 + '0';
FileName[5] = now.year()%10 + '0';
yearupg=now.year();
if (Firebase.ready() && currentTime - timeStorage >= intervalStorage)
{
Serial.print("Upload file : ");
Serial.println(FileName);
if (Firebase.Storage.upload(&fbdo, STORAGE_BUCKET_ID, String("/" + FileName).c_str(), mem_storage_type_sd, FileName.c_str(), "data.txt"))
Serial.printf("\nDownload Link: %s\n", fbdo.downloadURL().c_str());
else
Serial.println(fbdo.errorReason());
timeStorage = currentTime;
}
the error :
** error: invalid operands of types 'const char [2]' and 'char [11]' to binary 'operator+'
278 | if (Firebase.Storage.upload(&fbdo, STORAGE_BUCKET_ID, String("/" + FileName).c_str(), mem_storage_type_sd, FileName.c_str(), "data.txt"))
| ~~~ ^ ~~~~~~~~
| | |
| | char [11]
| const char [2]
error: request for member 'c_str' in 'FileName', which is of non-class type 'char [11]'
278 | if (Firebase.Storage.upload(&fbdo, STORAGE_BUCKET_ID, String("/" + FileName).c_str(), mem_storage_type_sd, FileName.c_str(), "data.txt"))
| ^~~~~
exit status 1
invalid operands of types 'const char [2]' and 'char [11]' to binary 'operator+'**
