mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Fix lost extension for files with known mimetype
This commit is contained in:
parent
da6b0c0162
commit
59002bfb24
2 changed files with 11 additions and 6 deletions
|
@ -41,10 +41,7 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.provider.MediaStore.Audio;
|
|
||||||
import android.provider.MediaStore.Images;
|
import android.provider.MediaStore.Images;
|
||||||
import android.provider.MediaStore.Video;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
@ -535,7 +532,6 @@ public class Uploader extends FileActivity
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public void uploadFiles() {
|
public void uploadFiles() {
|
||||||
try {
|
try {
|
||||||
// this checks the mimeType
|
|
||||||
for (Parcelable mStream : mStreamsToUpload) {
|
for (Parcelable mStream : mStreamsToUpload) {
|
||||||
|
|
||||||
Uri uri = (Uri) mStream;
|
Uri uri = (Uri) mStream;
|
||||||
|
@ -558,8 +554,14 @@ public class Uploader extends FileActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
displayName = (columnValues != null) ? columnValues[0] :
|
displayName = (columnValues != null) ? columnValues[0] :
|
||||||
uri.getLastPathSegment().replaceAll("\\s", "") + "."
|
uri.getLastPathSegment().replaceAll("\\s", "");
|
||||||
+ MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
|
||||||
|
// Add extension if it does not exists in the file name
|
||||||
|
int index = displayName.lastIndexOf(".");
|
||||||
|
if(index != -1 || MimeTypeMap.getSingleton().
|
||||||
|
getMimeTypeFromExtension(displayName.substring(index)) == null) {
|
||||||
|
displayName += "." + MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (uri.getScheme().equals("file")) {
|
} else if (uri.getScheme().equals("file")) {
|
||||||
filePath = Uri.decode(uri.toString()).replace(uri.getScheme() +
|
filePath = Uri.decode(uri.toString()).replace(uri.getScheme() +
|
||||||
|
@ -856,6 +858,7 @@ public class Uploader extends FileActivity
|
||||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
||||||
Log_OC.d(TAG, message);
|
Log_OC.d(TAG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -129,6 +129,8 @@ public class CopyTmpFileAsyncTask extends AsyncTask<Object, Void, String> {
|
||||||
if (listener!= null)
|
if (listener!= null)
|
||||||
{
|
{
|
||||||
listener.onTmpFileCopied(result, mIndex);
|
listener.onTmpFileCopied(result, mIndex);
|
||||||
|
} else {
|
||||||
|
Log_OC.e(TAG, "Lost upload because of lost context.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue