-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP - help wanted] attempt at getting data-uri based image upload working #3619
Conversation
Hi @siaw23 this seemed like something you might "just know" -- i dunno. Got a bit stuck, so if anything here makes sense to you, i'd love some help! |
Also noting that Paperclip is deprecated but it will likely take us a while to move to ActiveStorage: https://github.com/thoughtbot/paperclip/blob/master/MIGRATING.md |
I also don't see that ActiveStorage has data-uri uploads... er maybe? rails/rails@c2ba530 and we are looking at potentially doing CDN integration for images, and ActiveStorage maybe doesn't yet support this? https://stackoverflow.com/questions/50676891/rails-activestorage-link-to-cloudfront But... maybe? rails/rails#31419 (comment) Anyways we cross that bridge when we get to it. We can move these notes into a separate issue. |
Generated by 🚫 Danger |
Haha, it passes tests. Whoops. We'll need a test. |
there we go! |
Confirmed that this works using the following script, from JavaScript console on any PublicLab.org page: var token = "r0bzzuKtNIF8HpQmSmTndzNM+a1ndsWm/keBtL9nQZaWav70zqSM1bv+hsNqT9fDmvJZrtMKii2xF2md8MylkQ=="; // CSRF token
var data = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
$.post('/images/create', { authenticity_token: token, data: data, uid: 1, photo: { title: '', notes: '' } }, console.log); |
however, we need to set the filename to end in |
…rking (publiclab#3619) * attempt at getting data-uri based image upload working * test * dataurl fix with photo attribute * one more attribute tweak
Guidance (not working): https://stackoverflow.com/questions/23675747/use-paperclip-for-saving-base64-images-obtained-from-an-api?noredirect=1&lq=1
https://github.com/thoughtbot/paperclip/blob/f384174392ce192c9d76bd447902fe8a3ecf70ad/README.md#io-adapters
From a note page, i'm trying (in javascript console):
But getting: