Share files with sanitized name and suffix

This commit is contained in:
M66B
2019-03-14 09:12:19 +00:00
parent c4fa598fcf
commit 1902dacb63
7 changed files with 1589 additions and 100 deletions

View File

@@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.text.TextUtils;
import java.io.File;
import java.io.IOException;
@@ -79,7 +80,10 @@ public class EntityAttachment {
File dir = new File(context.getFilesDir(), "attachments");
if (!dir.exists())
dir.mkdir();
return new File(dir, Long.toString(id));
String filename = Long.toString(id);
if (!TextUtils.isEmpty(name))
filename += "." + Helper.sanitizeFilename(name);
return new File(dir, filename);
}
static void copy(Context context, long oldid, long newid) {