Feature #3989

MUST provide an easy way to download source J3M metadata as plaintext / json

Added by n8fr8 about 3 years ago. Updated about 3 years ago.

Status:ResolvedStart date:11/05/2014
Priority:NormalDue date:
Assignee:megabulk% Done:

0%

Category:-
Target version:InformaCam - SERVER v2
Component:

History

#1 Updated by harlo about 3 years ago

  • Assignee set to megabulk

If a document has a j3m, it will be in the "assets" field of the document wrapper as "j3m.json". You can then access it at this url: /files/.data/{{ doc id }}/j3m.json

Let me know if you need more info...

#2 Updated by megabulk about 3 years ago

  • Status changed from New to Resolved

It's done, not too pretty yet, but done… unless there's a better way of force-downloading plaintext files I'm not aware of.

#3 Updated by megabulk about 3 years ago

Do I need to provide options for download, like TSV, CSV, HTML? Or is the raw JSON good enough?

#4 Updated by n8fr8 about 3 years ago

JSON is fine for now. Creating tools to convert JSON into other formats is a different feature request.

Ultimately, I want a well-formed permalink like /submission/1234/json or /submission/1234.json

#5 Updated by megabulk about 3 years ago

Right now I've got a link that, when clicked, downloads the raw JSON file (but it's not a permalink). Do you want this well-formed permalink to begin a download, or should it just display the JSON in the browser?

#6 Updated by n8fr8 about 3 years ago

By "not a permalink" do you mean it requires a session key / cookie?

#7 Updated by megabulk about 3 years ago

Right now I'm cramming the JSON data into the href attribute, which forces it to download as a text file. It's nifty, but there's no permalink.
But if you want a permalink, I'll rethink it.

var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(this.model));
            this.$el.html('<a href="data:' + data + '" download="data.json">download JSON</a>');

#8 Updated by n8fr8 about 3 years ago

  • Status changed from Resolved to In Progress
  • Assignee changed from megabulk to harlo

Hmm... maybe this is more a @Harlo thing then? In terms of providing server permalinks to raw data?

#9 Updated by harlo about 3 years ago

  • Assignee changed from harlo to megabulk

The permalink to any asset in the Document Header is available at /files/.data/{{ _id }}/{{ asset }}. See for how I implement file downloads: https://github.com/harlo/UnveillanceInterface/blob/master/web/js/modules/uv_unveil.js#L17

However, there is no csv version of the j3m. So we have two options here.those would have to be created in javascript from the json dynamically, or we could tell the server to automatically create a csv asset based off of the json. What do we think?

#10 Updated by harlo about 3 years ago

We might also have better, more user-friendly urls to that same asset: so perhaps a function that maps requests to files/.data/blahblah to "/submission/{{ _id }}/assets/blahblah" or something better...

#11 Updated by n8fr8 about 3 years ago

harlo wrote:

We might also have better, more user-friendly urls to that same asset: so perhaps a function that maps requests to files/.data/blahblah to "/submission/{{ _id }}/assets/blahblah" or something better...

We don't need CSV for now.

Nicer permalink would be great, but if it already exists, just use the current one for this release.

#12 Updated by megabulk about 3 years ago

  • Status changed from In Progress to Resolved

Also available in: Atom PDF