Hello,
I have a problem with Firebase Storage.
Please point it out if there is a mistake in how to use it.
This has been discussed in other topics,
so if it is an issue, please add Firebase Storage to tests for next version. Uploading image on iOS
The results are as follows:
Android
NoSecure:OK, Secure:NG("Permission denied.")
iOS
NoSecure:NG, Secure:NG
The rule of Storage:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /NoSec/{allPaths=} {
allow read, write: if true;
}
match /Secure/{allPaths=} {
allow read, write: if request.auth != null;
}
}
}
According to https://doesappinventorrunonios.com/Firebase does not work with ios yet. Search in the above link for Components>Experimental>FirrebaseDB.to see the documentation.
I'm sure you're the owner.
With your information below, I was able to create an app with Firebase Authentication, Realtime Database and Storage using a web component.
METRIC RAT AI2 Registration & Login with Firebase Authentication
METRIC RAT AI2 Firebase with a Web Component
Thank you.But I can't solve this problem.
Has anyone experienced this?
A valid firebase user must sign in to get their valid idToken, this must then be passed to the firebase storage POST/GET request.
Ensure your firebaseStorage rules are correct as per my guide:
For the firebase storage, I will use rules that allow authenticated
users to read and write everything, within the FBDEMO folder:
rules_version = '2';
service firebase.storage {
match /b/myProject.appspot.com/o {
match /FBDEMO/{allPaths=**} {
allow read: if request.auth != null
allow write: if request.auth != null;
}
}
}
I used your rules and it worked fine.
But, I changed it back to the first rule below and it worked fine.
(allow read, write: if request.auth != null;)
Probably my mistake.
The iOS issue remains.
Thank you for your help.
Whilst I do not have an iOS device to test, I cannot see why a fairly simple web POST or GET request does not work.
Try without secure rules, and report back on the output from Firebase returned in the Web1.GotText responseContent. The raw response from firebase is always a json...
Ensure that your filePath in IOS is correct, I am aware these look quite different to those on Android, and that the file in question has read permissions for the web component.
Can you try a simple web GET request to another/different url ?
####About the file path####:
It is obtained using ImagePicker component.
The example of file path is follow.
/var/mobile/Containers/Data/Application/8B26D756-D2DE-444A-B745-AE8E5712B0B5/Library/Application Support/AppInventor/asset.JPG
The image is displayed on the screen.
####another/different url####
The PostText block for chatGPT API works fine.
The Get block for Google Books API works fine.
Looking at the responseContent for both, I would initially guess that Firebase is not getting the file. Let me do a little bit of testing, and I will come back with a few suggestions.
If that doesn't work try with image/png as the content-type.
Please show your relevant blocks, just so we can be sure they are correct.
I am drawn back to your filepath as well, you provide what appears to be a relative or absolute path, we may be requiring a full path...on Android it would look like this for a file picked in the Download folder, which is then copied to the ASD: file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Pictures/_app_inventor_image_picker/picked_image1565366041313282111.png
The iOS file/storage system is and remains a black box. For example, if I download a file from my server via the web component, I can't specify a fixed path. I see the result (the path) at the end, but I can't check whether the file exists either via the file manager or programmatically. The only option is to use a component that attempts to access the path (the file) and determine whether the file actually exists there. If the attempt fails, I have to download the file again and see that a new path is created.
This is one of the main reasons why I've currently paused development of my iOS apps. Since only 30MB is available for the aia (IPA), I have to download larger files in advance. After some time or after restarting the iOS device, the files/paths seem to disappear, so I have to start a complicated and time-consuming procedure before each restart of the app to ensure the existence of all files.
wvFBS.aia worked in my environment.
there is not the measurementId parm at Firebase Config of my project.
I skiped to set this parm.
Thank you for your help.
It seems like there's a permission issue with Firebase Storage. The error 'Permission denied' on Android and iOS suggests that the security rules are not configured correctly. Double-checking the storage rules and ensuring that the correct bucket and path are being referenced may resolve the issue.
I disagree. The issue appears to be that the POSTFile block is not getting a proper "fix" on the path to the file. This is demonstrated by the outputs shown by the OP above, and from previous posts by @Anke it is not just when trying to upload a file to Firebase Storage.