Версия 1.0
Александр Сушко
<?xml version="1.0" encoding="windows-1251"?>
<Файл xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ИдФайл="ON_DOCNPNO_6321422260632101001_6321422260632101001_0093_20180704_f9123170cc014fe5bff51ccbb10f8aa6" ВерсПрог="Налог3-А" ВерсФорм="5.01" xsi:noNamespaceSchemaLocation="ON_DOCNPNO_1_886_00_05_01_01.xsd">
<Документ КНД="1184002" ДатаДок="28.12.2017">
<СвОтпрДок>
<ОтпрНО КодНО="0093" НаимНО="0093" />
</СвОтпрДок>
<СвПолДок>
<ОтпрЮЛ НаимОрг="ООО "ШУЛЕР СЕРВИС РУС"" ИННЮЛ="6321422260" КПП="632101001" />
</СвПолДок>
<СвНП>
<НПЮЛ НаимОрг="ООО "ШУЛЕР СЕРВИС РУС"" ИННЮЛ="6321422260" КПП="632101001" />
</СвНП>
<Подписант Должн="Руководитель">
<ФИО Фамилия="Reg" Имя="Ofd" Отчество="Test" />
</Подписант>
<ДокНапрИзНО ИдФайлЗаяв="KO_ZVLREGKKT_0093_0093_6321422260632101001_20180704_defd99c90e3e4035809c666366675770">
<ИнфСообДок КНД_Док="1110211" НомФайлДок="167897" ДатаФайлДок="28.12.2017" КолФайл="1">
<ИмяФайл>1110211_0093_6321422260632101001_2b4edfd4-d702-4a6e-91e4-20d06731e178_20180704_2b4edfd4-d702-4a6e-91e4-20d06731e178</ИмяФайл>
</ИнфСообДок>
<ИнфСообДок КНД_Док="1110211" НомФайлДок="167897" ДатаФайлДок="28.12.2017" КолФайл="1">
<ИмяФайл>1110211_0093_6321422260632101001_3a3dde30-6c64-43ff-b129-79b0c471dee3_20180704_3a3dde30-6c64-43ff-b129-79b0c471dee3</ИмяФайл>
</ИнфСообДок>
</ДокНапрИзНО>
</Документ>
</Файл>
Фронтенд
Бэкенд
«Принтер»
Фронтенд
Бэкенд
«Принтер»
fetch("/api")
.then(function(response) {
return response.json();
})
.then(function(data) {
window.location.href = data.fileUrl;
});
// console.log(response);
{
type: "application/pdf",
size: 12345,
fileContent: "SGVsbG8sIHdvcmxkIQ..."
}
// console.log(response);
{
type: "application/pdf",
size: 12345,
fileContent: "SGVsbG8sIHdvcmxkIQ..."
}
public class Print
{
public Guid Id { get; set; }
public string Type { get; set; }
public int Size { get; set; }
public byte[] FileContent { get; set; }
}
fetch("/api")
.then(function(response) {
return response.json();
})
.then(function(data) {
const { type, fileContent } = data;
window.location.href =
`data:${type};base64,${fileContent}`;
});
async function downloadFile(filename) {
const response = await api.getFile();
const blob = new Blob([response.content], {type: response.type});
if (isMsBlob) {
window.navigator.msSaveBlob(blob, filename);
} else {
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
setTimeout(function() {
window.URL.revokeObjectURL(link.href);
document.body.removeChild(link);
}, 0);
}
}
const binString = window.atob(content);
const buffer =
new Uint8Array(binString.length);
for (let i = 0; i < binString.length; i++) {
buffer[i] = binString.charCodeAt(i);
}
const blob = new Blob([buffer], { type });
async function download(filename) {
const response = await api.getFile();
const binString = window.atob(response.content);
const buffer = new Uint8Array(binString.length);
for (let i = 0; i < binString.length; i++) {
buffer[i] = binString.charCodeAt(i);
}
const blob = new Blob([buffer], { type: response.type });
if (isMsBlob) {
window.navigator.msSaveBlob(blob, filename);
} else {
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
setTimeout(function() {
window.URL.revokeObjectURL(link.href);
document.body.removeChild(link);
}, 0);
}
}
const files =
document.querySelector("input[type=\"file\"]").files;
for (let file of files) { /*...*/ }
files.item(0);
{
lastModified,
lastModifiedDate,
name
}
const file = new File(blob, filename, options);
blob:https://example.org/9115d58c-bcda-ff47-86e5-083e...
/* Создание */
const link = window.URL.createObjectURL(file || blob);
/* Удаление */
window.URL.revokeObjectURL(link);
const filereader = new FileReader();
filereader.readAsText(file || blob);
const blob = new Blob(
[ blob || arrayBuffer || string ],
{ type, endings }
);
blob.slice( start, end, type );
xhr.responseType = "blob";
xhr.addEventListener("load", function() {
html5player.srcObject = xhr.response;
});
fetch("/video-stream.php")
.then(function(response) {
return response.blob();
})
.then(function(blob) {
html5player.srcObject = blob;
});
const canvas = document.querySelector("canvas");
canvas.toBlob(function(blob) {
const link = window.URL.createObjectURL(blob);
image.src = link;
image.addEventListener("load", function() {
window.URL.revokeObjectURL(link);
});
});
async function download(filename) {
const response = await api.getFile();
const binString = window.atob(response.content);
const buffer = new Uint8Array(binString.length);
for (let i = 0; i < binString.length; i++) {
buffer[i] = binString.charCodeAt(i);
}
const blob = new Blob([buffer], { type: response.type });
if (isMsBlob) {
window.navigator.msSaveBlob(blob, filename);
} else {
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
setTimeout(function() {
window.URL.revokeObjectURL(link.href);
document.body.removeChild(link);
}, 0);
}
}
Фронтенд
Бэкенд
«Принтер»
Фронтенд
Бэкенд
«Принтер»
Хранилище
Фронтенд-разработчик, СКБ Контур
TypedArray
http://wiki.amperka.ru/js:typedarray
http://2ality.com/2015/09/typed-arrays.html
Working With Files in JavaScript
http://blog.brew.com.hk/working-with-files-in-javascript
Bytes and Blobs