Closed simonry14 closed 4 years ago
Hi simonry14, the getUploadToken requires a pin that is generated on the server. You need to enter this pin in order to upload. Can you double check that you entered the correct pin?
Yeah, you should generate a bunch of pin codes to upload data. You can use setUploadCodes function from getUploadToken.ts file. But to invoke it you should make some changes to source code, now it's just an unused function.
I did manage to get a test pin ('1234') into Firestore, by adding a line at the beginning of getUploadToken() in getUploadToken.ts, that calls "await storeUploadCodes(['1234']);". Afterwards I could see in Cloud Firestore Database a "codes" collection, with an "uploadCode" document.
After doing this, the app still said Invalid Pin, although getUploadToken() executed successfully on the server and returned status: "SUCCESS" and the base64 encoded token to the client. The reason was an exception on the client-side related to SimpleDateFormat('YYYYMMdd') in uploadToCloudStorage() from EnterPinFragment.kt. I've changed the format string to 'yyyyMMdd' and now the whole uploading works, and I see my data inside the upload storage bucket, as unencrypted json.
And I remembered one important thing. I added in the getUploadToken.ts function trimming logic:
valid = uploadCodes.find(x => x.trim() === data.trim()) !== undefined;
It will protect you from insufficient error if you entered spaces accidentally.
@ValentinRadoi can you please share how the code look like that you the added the await storeUploadCodes(['1234']); thanks in advance.
Thanks all for the feedback. I resolved it by following @ValentinRadoi's advice.
Hey @simonry14 , It will be better if you share your solution with others too
undefined
Can u plz share @rinekri Where it need to be add ?
Thanks all for the feedback. I resolved it by following @ValentinRadoi's advice.
Can u plz share the solution with class name. @simonry14
@rinekri I'm facing with the below issue when trying to upload data : _Error: 9 FAILEDPRECONDITION: The Cloud Firestore API is not available for Datastore Mode projects. Could you pls help me on this?
I did manage to get a test pin ('1234') into Firestore, by adding a line at the beginning of getUploadToken() in getUploadToken.ts, that calls "await storeUploadCodes(['1234']);". Afterwards I could see in Cloud Firestore Database a "codes" collection, with an "uploadCode" document.
After doing this, the app still said Invalid Pin, although getUploadToken() executed successfully on the server and returned status: "SUCCESS" and the base64 encoded token to the client. The reason was an exception on the client-side related to SimpleDateFormat('YYYYMMdd') in uploadToCloudStorage() from EnterPinFragment.kt. I've changed the format string to 'yyyyMMdd' and now the whole uploading works, and I see my data inside the upload storage bucket, as unencrypted json.
Not helped @valr2. i hev entered verification code in Enter pin number and changed 'yyyyMMdd' too. but still facing issue.
@Hoangtho11188 It seems you should change Firestore Mode to Native.
I did manage to get a test pin ('1234') into Firestore, by adding a line at the beginning of getUploadToken() in getUploadToken.ts, that calls "await storeUploadCodes(['1234']);". Afterwards I could see in Cloud Firestore Database a "codes" collection, with an "uploadCode" document.
After doing this, the app still said Invalid Pin, although getUploadToken() executed successfully on the server and returned status: "SUCCESS" and the base64 encoded token to the client. The reason was an exception on the client-side related to SimpleDateFormat('YYYYMMdd') in uploadToCloudStorage() from EnterPinFragment.kt. I've changed the format string to 'yyyyMMdd' and now the whole uploading works, and I see my data inside the upload storage bucket, as unencrypted json.
This has not worked for me. I added the await storeUploadCodes(['1234']); line to see if that helps but its giving me this Invalid key length error:
I did manage to get a test pin ('1234') into Firestore, by adding a line at the beginning of getUploadToken() in getUploadToken.ts, that calls "await storeUploadCodes(['1234']);". Afterwards I could see in Cloud Firestore Database a "codes" collection, with an "uploadCode" document.
After doing this, the app still said Invalid Pin, although getUploadToken() executed successfully on the server and returned status: "SUCCESS" and the base64 encoded token to the client. The reason was an exception on the client-side related to SimpleDateFormat('YYYYMMdd') in uploadToCloudStorage() from EnterPinFragment.kt. I've changed the format string to 'yyyyMMdd' and now the whole uploading works, and I see my data inside the upload storage bucket, as unencrypted json.
This has not worked for me. I added the await storeUploadCodes(['1234']); line to see if that helps but its giving me this Invalid key length error:
Code should have minimum 6 symbols, try to add 123456 code number.
Code should have minimum 6 symbols, try to add 123456 code number.
Hey @rinekri tried that and am getting the same thing unfortunately. What do you think I am missing?
After some investigating, the Invalid key length is coming from the key I generated and uploaded to the Secret Manager. I have set it up correctly I believe and it passes all my tests. My default encryption algorithm is "aes-256-gcm".
Not sure where I am going wrong.
EDIT:
I was able to successfully upload a key by doing this
const key_in_bytes = Buffer.from("FKdDh0d0qUv4FByKxwkZtCPfR87uspUwEokBFRQll5w=", 'base64')
and passing that instead of this.key
(And similar thing with the same base64 string to the decrypt function)
This means I did something weird with how I generated the key possibly with the head -c32 /dev/urandom | base64
line
So still not sure what the issue there is.
@LorsK You can add logging of encryption key from SecretManager in the encrypt function. Maybe problem isn't in key itself, but in the way how you added it in the Manager. You could copy key with spaces, new lines and etc.
@rinekri I getuploadtoken success from my side So how to upload data to Storage bucket? My Upload bucket still is empty now.
@Hoangtho11188 I'm having the same issue. Getting this error on checking the logs: E/StorageException: StorageException has occurred. User does not have permission to access this object. Code: -13021 HttpResult: 403 E/StorageException: The server has terminated the upload session
Were you able to fix it?
"await storeUploadCodes(['1234']);"
hello, can you please specify where did you put this "await storeUploadCodes(['1234']);" line? It will be extremely helpful. Thank you.
Thanks for the good work.
Whenever I try to upload data I get an invalid pin error message.
I have followed all the cloud functions instructions and the tests all run successfully.
Please kindly advise what I might be missing