mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Setting content type properly in readAsDataURL
This commit is contained in:
parent
46f0bf60c4
commit
43c72e684c
@ -16,6 +16,7 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.phonegap.api.Plugin;
|
||||
import com.phonegap.api.PluginResult;
|
||||
@ -219,8 +220,11 @@ public class FileUtils extends Plugin {
|
||||
}
|
||||
|
||||
// Determine content type from file name
|
||||
// TODO
|
||||
String contentType = "";
|
||||
MimeTypeMap map = MimeTypeMap.getSingleton();
|
||||
String contentType = map.getMimeTypeFromExtension(map.getFileExtensionFromUrl(filename));
|
||||
if (contentType == null && filename.startsWith("content")) {
|
||||
contentType = "image/jpeg";
|
||||
}
|
||||
|
||||
byte[] base64 = Base64.encodeBase64(bos.toByteArray());
|
||||
String data = "data:" + contentType + ";base64," + new String(base64);
|
||||
|
Loading…
Reference in New Issue
Block a user