Browse Source

文件下载增加前缀信息

zk 1 year ago
parent
commit
e47f567ec9

+ 1 - 1
app/src/main/java/com/atmob/voiceai/module/result/VoiceResultViewModel.java

@@ -163,7 +163,7 @@ public class VoiceResultViewModel extends BaseViewModel {
         }
         VoiceFileUtil.getVoiceFile(okHttpClient, userVoiceBean.getVoiceUrl())
                 .map(file -> {
-                    MediaStoreHelper.saveToSharedStorage(MediaStoreHelper.TYPE_AUDIO, file, getVoiceFileName());
+                    MediaStoreHelper.saveToSharedStorage(MediaStoreHelper.TYPE_AUDIO, file, file.getName());
                     return file;
                 })
                 .subscribe(new SingleObserver<File>() {

+ 2 - 0
app/src/main/java/com/atmob/voiceai/utils/DownloadUtils.java

@@ -18,6 +18,8 @@ import atmob.reactivex.rxjava3.schedulers.Schedulers;
 
 public class DownloadUtils {
 
+    public static final String FILE_PREFIX = "VoiceAI_";
+
     public static File voiceFile = getVoiceSaveRootFile();
 
     private DownloadUtils() {

+ 2 - 2
app/src/main/java/com/atmob/voiceai/utils/VoiceFileUtil.java

@@ -23,7 +23,7 @@ public class VoiceFileUtil {
     public static Single<File> getVoiceFile(OkHttpClient okHttpClient, @NonNull String url) {
         return Single.create((SingleOnSubscribe<File>) emitter -> {
                     File localFile = net2LocalFile(url);
-                    DownloadUtils.downLoadCompareBeforeLocal(okHttpClient, url, localFile, DownloadUtils.voiceFile, getFileName(url), new FileDownLoadObserver<File>() {
+                    DownloadUtils.downLoadCompareBeforeLocal(okHttpClient, url, localFile, DownloadUtils.voiceFile, DownloadUtils.FILE_PREFIX + getFileName(url), new FileDownLoadObserver<File>() {
                         @Override
                         public void onDownLoadStart() {
 
@@ -45,7 +45,7 @@ public class VoiceFileUtil {
     }
 
     private static File net2LocalFile(@NonNull String url) {
-        String fileName = getFileName(url);
+        String fileName = DownloadUtils.FILE_PREFIX + getFileName(url);
         return new File(DownloadUtils.voiceFile, fileName);
     }