Reputation: 2920
I am successfully uploading images using AngularFire2 to Firebase Storage.
I have the following upload code.
this.AfStorage.ref(`images/${userId}/${timeStamp}`).putString(base64Image,'data_url');
There are a few issues that I want to solve.
If there are no firebase server size solutions do suggest some client size solutions.
Thanks
Upvotes: 3
Views: 1609
Reputation: 598817
To limit the size of uploads, see this example from the documentation:
service firebase.storage { match /b/{bucket}/o { match /images { // Cascade read to any image type at any path match /{allImages=**} { allow read; } // Allow write files to the path "images/*", subject to the constraints: // 1) File is less than 5MB // 2) Content type is an image // 3) Uploaded content type matches existing content type // 4) File name (stored in imageId wildcard variable) is less than 32 characters match /{imageId} { allow write: if request.resource.size < 5 * 1024 * 1024 && request.resource.contentType.matches('image/.*') && request.resource.contentType == resource.contentType && imageId.size() < 32 } } } }
There is no way to limit the number of files with security rules, so you'll have to look at workarounds such as shown here:
Upvotes: 3