-
Notifications
You must be signed in to change notification settings - Fork 5
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
Ability to specify a data-url response (or just a JPG) instead of HTML wrapping a data-url #36
Comments
image-sequencer-app/src/api/v2/index.js Lines 71 to 79 in dca8158
|
Actually we should just redirect to a JSON status file that's actually stored in Google Cloud, which we are periodically updating as the export progresses. |
See how here, we create a JSON file with the status, and repeatedly save it to Google Cloud storage as the process continues. And we report the location of that file back to the user immediately, so they can fetch it as often as they like without running any process on the exporter itself: https://github.com/publiclab/mapknitter-exporter-sinatra/blob/main/app.rb#L119-L187 |
Okay! This makes sense! So we just make and store a json file in the google cloud and update it periodically! Hmm, I wonder if this file could be stored locally? Since this file can be deleted after the export completes I'm not entirely sure if keeping it in the cloud would be a good idea, don't you think? |
We actually want a permanent record of the status -- that's how the Ruby
exporter works. Thank you!!!
…On Sat, Dec 21, 2019 at 1:23 AM Varun Gupta ***@***.***> wrote:
Okay! This makes sense! So we just make and store a json file in the
google cloud and update it periodically! Hmm, I wonder if this file could
be stored locally? Since this file can be deleted after the export
completes I'm not entirely sure if keeping it in the cloud would be a good
idea, don't you think?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#36?email_source=notifications&email_token=AAAF6J6U65XMCJYFU2XPPA3QZWY6PA5CNFSM4JXCVBGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHOWFAQ#issuecomment-568156802>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J37ZKAJOGZNIWHPQP3QZWY6PANCNFSM4JXCVBGA>
.
|
Oh! Okay! I'll get started on this then! 😃 |
Noting also possibility of uploading the JPG to Google Cloud Storage as well; i think it would involve changing these lines: image-sequencer-app/src/api/v2/util/process-multisequencer.js Lines 66 to 79 in 744b521
I guess it would be, instead, something like (ref): var data = out.replace(/^data:image\/\w+;base64,/, ""); // strip off the data: url prefix to get just the base64-encoded bytes
var buf = new Buffer(data, 'base64');
var filename = `export${pid}.jpg`
var imgPath = path.join(__dirname, `../../../../temp/${filename}`);
fs.writeFileSync(imgPath, buf);
mapknitterBucket.upload(imgPath, {
gzip: true
}).then(() => {
mapknitterBucket
.file(filename)
.makePublic();
fs.unlinkSync(path.join(__dirname, imgPath));
mapknitterBucket.file(filename)
.getMetadata()
.then((data) => changeStatus("uploaded", data[0].mediaLink)); |
OK i made a PR here: #36 But we will also need to change the status.json output file to now point at the correct JPG file. |
Ah no, that will happen here:
So this might just work...? |
We should make a parameter called
response=
which can be set toresponse=html
orresponse=dataurl
maybe?The text was updated successfully, but these errors were encountered: