Puppet Box: Now with Real Image Files!
Now that I know how to upload files in Node.js, I’ve ditched the data urls. Instead, we’re doing real live file uploads via XHR with a FormData attached. I’m so glad browsers can finally represent Form Data!
As an extra level of efficiency, the client hashes the file’s binary data and does a HEAD request to check if the server already has that file. It knows exactly where to look since the files are all named after their sha256 anyway.
Unfortunately, the hash I’m doing of the real file on the server side doesn’t agree with the hash of the binary string on the client side. To work around this, I’m just trusting the client for now. Please don’t be a meanie and exploit this.
Anyway, the whole thing should be a great deal more efficient now. Try it out! Now I just need some more features, like stacking and save states. Also it’s still on a janky test server and not guaranteed to be up. I’ll deploy it properly eventually.