Skip to content

Commit

Permalink
Merge pull request #16 from phyloref/gzip-jsonld
Browse files Browse the repository at this point in the history
When trying to host JPhyloRef on my own server, I found that files were being uploaded too slowly. This PR updates the Open Tree Resolver so that it uploads the file as a Gzipped string to save time. Requires a JPhyloRef that supports phyloref/jphyloref#63.
  • Loading branch information
gaurav authored Jan 2, 2020
2 parents 2a41299 + 67b0182 commit dae71e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ import { PhylogenyWrapper, TaxonomicUnitWrapper } from '@phyloref/phyx';
import Vue from 'vue';
import { signer } from 'x-hub-signature';
import { saveAs } from 'filesaver.js-npm';
import zlib from 'zlib';
// Navigation controls.
import TopNavigationBar from './components/TopNavigationBar.vue';
Expand Down Expand Up @@ -542,9 +543,14 @@ export default {
// file into JSON-LD.
const outerThis = this;
Vue.nextTick(function () {
// Convert phylorefs and phylogeny to JSON-LD.
const jsonld = outerThis.getPhylorefsAndPhylogenyAsOntology();
const jsonldGzipped = zlib.gzipSync(jsonld);
// Prepare request for submission.
const query = jQuery.param({
jsonld: outerThis.getPhylorefsAndPhylogenyAsOntology(),
// Convert Gzipped data into a string in Base64.
jsonldGzipped: Buffer.from(jsonldGzipped).toString('base64')
}).replace(/%20/g, '+'); // $.post will do this automatically,
// but we need to do this here so our
// signature works.
Expand Down

0 comments on commit dae71e0

Please sign in to comment.