Public
Edited
Nov 23
1 star
Insert cell
Insert cell
Insert cell
fflate = require('fflate@0.8.2/umd/index.js')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable lastdrop = null
Insert cell
mutable compressedFile = null
Insert cell
mutable ratio = null
Insert cell
async function filedrop(event){
const items = event.dataTransfer.items
event.preventDefault()
if (items[0].kind !== "file"){
return
}
const file = items[0].getAsFile()
mutable lastdrop = file
const buffer = await file.arrayBuffer()
const before = file.size
const uarray = new Uint8Array(buffer)
const result = fflate.compressSync(uarray, {
mtime: file.lastModified,
filename: file.name
})
const after = result.length
mutable compressedFile = result
mutable ratio = after / before
}
Insert cell
function dragOverHandler(ev) {
// Prevent default behavior (Prevent file from being opened)
ev.preventDefault();
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more