我使用AngularFire2成功将图片上传到Firebase存储。
我有以下上传代码。
this.AfStorage.ref(`images/${userId}/${timeStamp}`).putString(base64Image,'data_url');
我想解决一些问题。
如果没有firebase服务器大小解决方案,请建议一些客户端大小的解决方案。
由于
答案 0 :(得分:1)
To limit the size of uploads, see this example from the documentation中提取href:
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 } } } }
无法使用安全规则限制文件数量,因此您必须查看此处显示的解决方法: