[英]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.