简体   繁体   English

创建高达 50k 的文件并上传到 firebase

[英]create files up to 50k & upload to firebase

I wrote a program to save a series of data in a file and then upload it to firebase.我写了一个程序,将一系列数据保存在一个文件中,然后上传到firebase。 The problem is that when the file is uploaded, the new data replaces the old data and the old data is deleted.问题是文件上传时,新数据替换旧数据,旧数据被删除。 My solution to keep the previous data is to first create a file called "file2.txt" and save the data in it.我保留以前数据的解决方案是首先创建一个名为“file2.txt”的文件并将数据保存在其中。 Its volume will reach 50K and then this file will be uploaded and then a file called "file2.txt" will be created and when its volume reaches 50k it will be uploaded and the same process will continue.它的体积将达到 50K,然后将上传此文件,然后将创建一个名为“file2.txt”的文件,当其体积达到 50k 时,将上传并继续相同的过程。 Now my problem is that I have a problem to make this process of creating the files in order and then upload them.现在我的问题是我无法按顺序创建文件然后上传它们。 Please guide me with the source code.请用源代码指导我。

     String app_name ="app is name :"+applicationLabel;
            


            reference= FirebaseStorage.getInstance().getReference().child("Dcument").child("appName");
            reference.child("appname.txt").putBytes(app_name.getBytes()).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>()

If you upload the same file name again it will override the previous file so I have followed the below approach如果您再次上传相同的文件名,它将覆盖以前的文件,所以我遵循了以下方法

Upload files with different names:上传不同名称的文件:

To achieve this I have appended time in millis after file name so you can follow this approach or you can also follow any other approach to make each file name different为了实现这一点,我在文件名之后以毫秒为单位附加了时间,因此您可以遵循这种方法,或者您也可以遵循任何其他方法来使每个文件名不同

String fileName = "file2_" + System.currentTimeMillis() +".txt";

You can also create different different directories for each file but you need to manage naming and I would not recommend that approach您还可以为每个文件创建不同的不同目录,但您需要管理命名,我不推荐这种方法

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

相关问题 更新应用程序:向现有数据库添加新的预填充表(具有5万条记录) - Updating app: Adding a new pre-populated table (with 50k records) to an existing db 通过rest api获取超过50K的数据并存储到Android本地存储(SQLite) - Fetch more than 50K data through rest api and store into Android Local Storage(SQLite) 有什么办法可以一次在recyclerview中加载5到10个项目,而不是50k? - Is there any way to load 5 - 10 items in recyclerview at a time instead of 50k? Firebase 上传/下载 pdf 文件 - Firebase upload/download pdf files 是否可以一次将多个文件上传到 Firebase 存储 - is it possible to upload multiple files to firebase storage at once Firebase 存储 - 在 Android 中上传多个图像文件 - Firebase Storage - Upload multiple image files in Android 将多个文件上传到 Android 中的 firebase firestore - Upload multiple files to firebase firestore in Android 如何从 Android 上传多个文件到 Firebase? - How to upload multiple files to Firebase from Android? Firebase Storage真的需要用户上传文件吗? - Firebase Storage really needs a user to upload files? 如何按arraylist中的顺序将多个文件上传到firebase数据库? - how do I upload multiple files to firebase databse in order as in arraylist?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM