Я пытаюсь загрузить zip -файл для использования в моем приложении.var var_url = 'https://example.com/teste.zip'; // Location of the file to be downloaded
var fileURL = "///storage/emulated/0/Android/data/myapp/teste.zip"; // Save in this folder
var req = new XMLHttpRequest();
req.open("GET", var_url, true);
req.responseType = "blob";
req.onload = function (event) {
var blob = req.response;
alert(blob.size);
alert(blob.type);
alert("WORKS!");
alert(fileURL);
alert(var_url);
if (blob.size>52747758) { alert('This file is over 50 megabytes') } //52747758 or 50.30 megas
// cordova.file.etc is where you will save the file. In this case, inside the app folder, in the main storage in Android
window.resolveLocalFileSystemURL(cordova.file.externalApplicationStorageDirectory, function (directoryEntry) {
// the 'temp.pdf' is the name you want for your file.
directoryEntry.getFile('teste.zip', { create: true }, function (fileEntry) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function (e) {
// great success!
alert('Write of file completed.');
};
fileWriter.onerror = function (e) {
// Meh - fail
alert('Write failed');
};
fileWriter.write(blob);
} );
} );
});
};
req.send();
Подробнее здесь: https://stackoverflow.com/questions/795 ... nload-file
Cordova Android -файл скачать файл ⇐ Android
Форум для тех, кто программирует под Android
1745413291
Anonymous
Я пытаюсь загрузить zip -файл для использования в моем приложении.var var_url = 'https://example.com/teste.zip'; // Location of the file to be downloaded
var fileURL = "///storage/emulated/0/Android/data/myapp/teste.zip"; // Save in this folder
var req = new XMLHttpRequest();
req.open("GET", var_url, true);
req.responseType = "blob";
req.onload = function (event) {
var blob = req.response;
alert(blob.size);
alert(blob.type);
alert("WORKS!");
alert(fileURL);
alert(var_url);
if (blob.size>52747758) { alert('This file is over 50 megabytes') } //52747758 or 50.30 megas
// cordova.file.etc is where you will save the file. In this case, inside the app folder, in the main storage in Android
window.resolveLocalFileSystemURL(cordova.file.externalApplicationStorageDirectory, function (directoryEntry) {
// the 'temp.pdf' is the name you want for your file.
directoryEntry.getFile('teste.zip', { create: true }, function (fileEntry) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function (e) {
// great success!
alert('Write of file completed.');
};
fileWriter.onerror = function (e) {
// Meh - fail
alert('Write failed');
};
fileWriter.write(blob);
} );
} );
});
};
req.send();
Подробнее здесь: [url]https://stackoverflow.com/questions/79588683/cordova-android-download-file[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия