mirror of
https://github.com/24eme/signaturepdf
synced 2026-03-14 13:55:44 +01:00
storeFileName with parameters file and filename
Lors de la modification d'un pdf dans la page organisation, il faut prendre le pdf modifié et non le pdf dans l'input originel L'id de l'input était hardcodé dans la fonction
This commit is contained in:
parent
7561fae205
commit
cd5fd13f1c
4 changed files with 10 additions and 8 deletions
|
|
@ -60,10 +60,9 @@ async function loadFileFromCache(cacheUrl, pageUrl) {
|
|||
document.getElementById('input_pdf_upload').dispatchEvent(new Event("change"));
|
||||
}
|
||||
|
||||
async function storeFileInCache() {
|
||||
let cache = await caches.open('pdf');
|
||||
let filename = document.getElementById('input_pdf_upload').files[0].name;
|
||||
let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" });
|
||||
async function storeFileInCache(file, filename, cacheStore = 'pdf') {
|
||||
let cache = await caches.open(cacheStore);
|
||||
let response = new Response(file, { "status" : 200, "statusText" : "OK" });
|
||||
await cache.put('/pdf/'+filename, response);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -328,8 +328,9 @@ async function pageUpload() {
|
|||
})
|
||||
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
|
||||
if(await canUseCache()) {
|
||||
storeFileInCache();
|
||||
history.pushState({}, '', '/metadata#'+document.getElementById('input_pdf_upload').files[0].name);
|
||||
const file = document.getElementById('input_pdf_upload').files[0]
|
||||
storeFileInCache(file, file.name);
|
||||
history.pushState({}, '', '/metadata#'+file.name);
|
||||
}
|
||||
pageMetadata(null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -659,6 +659,7 @@ async function save(order) {
|
|||
|
||||
const newPDF = new Blob([await pdf.save()], {type: "application/pdf"});
|
||||
await download(newPDF, filename+".pdf");
|
||||
await storeFileInCache(newPDF, filename+'.pdf');
|
||||
}
|
||||
|
||||
function mm2points(mm) {
|
||||
|
|
|
|||
|
|
@ -1148,8 +1148,9 @@ async function pageUpload() {
|
|||
document.getElementById('input_pdf_upload').focus();
|
||||
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
|
||||
if(await canUseCache()) {
|
||||
storeFileInCache();
|
||||
history.pushState({}, '', '/signature#'+document.getElementById('input_pdf_upload').files[0].name);
|
||||
const file = document.getElementById('input_pdf_upload').files[0]
|
||||
storeFileInCache(file, file.name);
|
||||
history.pushState({}, '', '/signature#'+file.name);
|
||||
}
|
||||
pageSignature(null);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue