mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-25 02:40:11 +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 org.json.JSONObject;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
import com.phonegap.api.Plugin;
|
import com.phonegap.api.Plugin;
|
||||||
import com.phonegap.api.PluginResult;
|
import com.phonegap.api.PluginResult;
|
||||||
@ -219,8 +220,11 @@ public class FileUtils extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine content type from file name
|
// Determine content type from file name
|
||||||
// TODO
|
MimeTypeMap map = MimeTypeMap.getSingleton();
|
||||||
String contentType = "";
|
String contentType = map.getMimeTypeFromExtension(map.getFileExtensionFromUrl(filename));
|
||||||
|
if (contentType == null && filename.startsWith("content")) {
|
||||||
|
contentType = "image/jpeg";
|
||||||
|
}
|
||||||
|
|
||||||
byte[] base64 = Base64.encodeBase64(bos.toByteArray());
|
byte[] base64 = Base64.encodeBase64(bos.toByteArray());
|
||||||
String data = "data:" + contentType + ";base64," + new String(base64);
|
String data = "data:" + contentType + ";base64," + new String(base64);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user