mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-04-24 00:00:03 +08:00
594d03aa41
- feat(www): implement preprocessor for FormData instances - feat(www): implement API checks for multipart requests - feat(android): implement multipart requests - chore(specs): implement www specs for new prprocessor
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
module.exports = function init(global, console, messages) {
|
|
var interface = {
|
|
checkBlobApi: checkBlobApi,
|
|
checkFileReaderApi: checkFileReaderApi,
|
|
checkFormDataApi: checkFormDataApi,
|
|
checkTextEncoderApi: checkTextEncoderApi,
|
|
logWarnings: logWarnings,
|
|
};
|
|
|
|
return interface;
|
|
|
|
function logWarnings() {
|
|
if (!global.FormData) {
|
|
console.warn(messages.MISSING_FORMDATA_API);
|
|
} else if (!global.FormData.prototype || !global.FormData.prototype.entries) {
|
|
console.warn(messages.MISSING_FORMDATA_ENTRIES_API);
|
|
}
|
|
}
|
|
|
|
function checkBlobApi() {
|
|
if (!global.Blob || !global.Blob.prototype) {
|
|
throw new Error(messages.MISSING_BLOB_API);
|
|
}
|
|
}
|
|
|
|
function checkFileReaderApi() {
|
|
if (!global.FileReader || !global.FileReader.prototype) {
|
|
throw new Error(messages.MISSING_FILE_READER_API);
|
|
}
|
|
}
|
|
|
|
function checkFormDataApi() {
|
|
if (!global.FormData || !global.FormData.prototype || !global.FormData.prototype.entries) {
|
|
throw new Error(messages.MISSING_FORMDATA_ENTRIES_API);
|
|
}
|
|
}
|
|
|
|
function checkTextEncoderApi() {
|
|
if (!global.TextEncoder || !global.TextEncoder.prototype) {
|
|
throw new Error(messages.MISSING_TEXT_ENCODER_API);
|
|
}
|
|
}
|
|
};
|