mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-12 02:25:03 +00:00
Multipage working
This commit is contained in:
parent
f6e8f07afc
commit
ebd6aac715
@ -81,20 +81,18 @@ function setupFileInput(chooser) {
|
||||
}
|
||||
|
||||
const googleDriveFileListener = function (e) {
|
||||
const googleDriveFile = e.detail;
|
||||
const googleDriveFiles = e.detail;
|
||||
|
||||
const fileInput = document.getElementById(elementId);
|
||||
if (fileInput?.hasAttribute('multiple')) {
|
||||
allFiles.push(googleDriveFile);
|
||||
pushFileListTo(googleDriveFiles, allFiles);
|
||||
} else if (fileInput) {
|
||||
allFiles = [googleDriveFile];
|
||||
allFiles = [googleDriveFiles[0]];
|
||||
}
|
||||
|
||||
const dataTransfer = new DataTransfer();
|
||||
allFiles.forEach((file) => dataTransfer.items.add(file));
|
||||
|
||||
fileInput.files = dataTransfer.files;
|
||||
|
||||
fileInput.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { source: 'drag-drop' } }));
|
||||
}
|
||||
|
||||
|
@ -95,21 +95,23 @@
|
||||
*/
|
||||
async function pickerCallback(data) {
|
||||
if (data.action === google.picker.Action.PICKED) {
|
||||
data[google.picker.Response.DOCUMENTS].forEach(async pickedFile => {
|
||||
const files = await Promise.all(data[google.picker.Response.DOCUMENTS].map(async pickedFile => {
|
||||
const fileId = pickedFile[google.picker.Document.ID];
|
||||
console.log(fileId);
|
||||
const res = await gapi.client.drive.files.get({
|
||||
'fileId': fileId,
|
||||
'alt': 'media',
|
||||
});
|
||||
|
||||
|
||||
var file = new File([new Uint8Array(res.body.length).map((_, i) => res.body.charCodeAt(i))],
|
||||
pickedFile.name, {
|
||||
pickedFile.name, {
|
||||
type: pickedFile.mimeType,
|
||||
lastModified: pickedFile.lastModified,
|
||||
lastModified: pickedFile.lastModified,
|
||||
endings: pickedFile.endings
|
||||
} )
|
||||
document.body.dispatchEvent(new CustomEvent("googleDriveFilePicked", {detail: file}));
|
||||
});
|
||||
} );
|
||||
return file;
|
||||
}));
|
||||
|
||||
document.body.dispatchEvent(new CustomEvent("googleDriveFilePicked", {detail: files}));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user