简体   繁体   English

我想限制上传到firebase存储的pdf文件大小。 我希望该用户可以上传最大7MB的文件

[英]I want to limit the pdf file size uploaded to firebase storage. I want that user can upload a file with maximum size of 7MB

I want put a limitation on firebase storage. 我想对firebase存储设置限制。 That is user can upload a pdf file of maximum size of 7MB. 也就是说用户可以上传最大7MB的pdf文件。 And How can i reduce the size of pdf file? 我怎样才能减小pdf文件的大小? is there any way in android. 在android中有什么办法吗?

I don't know the solution of my question. 我不知道我的问题的解决方案。 I find a lot but doesn't get my answer. 我找到了很多,但没有得到我的答案。 Can someone help me with firebase security rules? 有人可以帮我解决firebase安全规则吗? I am not familiar with that doesn't find any answer about this. 我不熟悉,没有找到任何答案。

The Firebase documentation on security rules has an example that shows (amongst others) how to set the maximum size of files that can be stored: 有关安全规则Firebase文档中有一个示例,其中显示了(如此)如何设置可以存储的文件的最大大小:

 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 } } } } 

Since these rules will only be applied after the actual upload has completed (but before the file is actually stored in your storage bucket), you'll typically also want to check the file size in your Android app before uploading it, to prevent using bandwidth for a file that is too large. 由于这些规则仅在实际上传完成后应用(但在文件实际存储在存储桶中之前),因此您通常还需要在上传之前检查Android应用中的文件大小,以防止使用带宽对于太大的文件。 For some examples of how to check the local file size on Android, see Get the file size in android sdk? 有关如何在Android上检查本地文件大小的一些示例,请参阅在android sdk中获取文件大小?

Retrofit allows you to upload certain size only at a single time. Retrofit允许您仅在一次上传特定尺寸。 This site has detailed tutorial from basic to complicated series of articles. 本网站有从基础到复杂系列文章的详细教程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 App Engine Blobstore - 我该怎么做才能限制用户可以上传的文件大小? - App Engine Blobstore - What can I do to limit the size of a file that a user can upload? 我想检查是否有新文件添加到 firebase 存储中 - I want to check whether a new file is added to firebase storage or not 如果大小超过 10MB,我想删除文件夹 [暂停] - I want to delete folder if the size is above 10MB [on hold] 我想在 recyclerview 开始时显示上传到 firebase 存储的最新图像 - i want to display the newest image uploaded to firebase storage at the start of recyclerview 我想从手机的内部存储中获取以MB为单位选择的文件大小。 但是file.length()总是返回0 - I want to get the size of file i select in MBs from internal storage of my phone. but file.length() always returns 0 我已经生成了pdf文件,现在我不想下载文件,但是我想使用Java直接在ftp上上传文件 - I have genrated the pdf file now i dont want to download the file but i want to upload the file directly on ftp using java Java 中的最大文件上传大小 - Maximum File Upload Size in Java 如何在Java Servlet中限制上传文件的大小 - How to limit uploaded file size in java servlet 我的应用程序在我的设备上占用250mb内存。 当我进行堆转储并进行分析时。 它说堆大小约为7mb - My App is taking 250mb memory on my device. When I do a heap dump and analyze it. it says the heap size around 7mb 我如何询问用户是否要为文件添加新记录? - How can I question the user if they want to add a new record for a file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM