android - 如何从文件uri中提取文件名
问题描述
我制作了一个应用程序来将文件上传到firebase
存储并将其设置为firebase
. 一切正常,但是当我上传文件时,文件上传firebase
成功,但它重命名为唯一名称(对于System.currentTimeMillis())
,我如何保留其原始名称?(我试过getLastPathSegment().replaceFirst("[.][^.]+$",""))
但它没有用。
private void uploadFile(Uri pdfUri)
{
//uploading progress dialog
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle("Uploading file...");
progressDialog.setProgress(0);
progressDialog.show();
final String fileName = System.currentTimeMillis() + ".pdf"; //TODO use System.currentTimeMillis() if you want a unique name
final String fileName1 = System.currentTimeMillis() + "";
StorageReference storageReference = storage.getReference(); //returns parent path
解决方案
推荐阅读
- c# - 从 IDesignTimeDbContextFactory 访问 App.config
- swift - PropertyListEncoder 产生双倍的预期数据
- magento - Magento 2中只有一页的内部服务器错误,其余页面工作正常
- c# - 添加自定义 ILogger 类时安全连接失败
- ios - 一段时间后如何在标签中返回默认文本?
- vim - 如何防止 Vim 在 EOF 处为 LaTex 文件添加换行符?
- jquery - 从 Ajax 重新加载时,BootstrapTable 不显示复选框列
- c# - 在 C# 中使用“使用”的正确方法
- python - python pandas数据框同时应用多个html样式
- angular - 角度的自定义错误处理程序不起作用