publiclab / Leaflet.DistortableImage

A Leaflet extension to distort or "rubber sheet" images
https://publiclab.github.io/Leaflet.DistortableImage/examples/
BSD 2-Clause "Simplified" License
270 stars 284 forks source link

Generate URL from JSON data #1340

Closed 7malikk closed 1 year ago

7malikk commented 1 year ago

Please describe the desired behavior. onClick of a button, the current tile layer state including its already knitted images should be uploaded in JSON to Archive.org and a link should be generated and returned to the user.

7malikk commented 1 year ago

Hello everyone, although I have not successfully found a way to write new data to IA (the way we need to), here is my opinion from the research and attempts so far.

Going through the IA Developer Portal, I found various ways to communicate with IA, but I noticed that in all the various ways especially in cases of writing/updating data, the user had to parse in an Authorization header with values LOW <s3-access>:<s3-secret>, like so:

image this snippet can be found at Internet Archive Tasks API

After further digging, I found out that these values s3-access and s3-secret are available to each IA account.

My thoughts so far

I stand to be corrected, but I believe it'll be a tad impractical to require these keys from every user interested in sharing via URL.

Resources

Here are some of the resources I went through supporting my thoughts:

As I am still researching and performing some trials, I can not come to a conclusion just yet, I would also love to know what you all think. Thank you! @jywarren @PeculiarE @TildaDares @cesswairimu @segun-codes

Sidenote

As discussed and noted in our shared notes, we could work on a step-by-step guide on how to upload JSON files to IA, all within a modal triggered by the share button.

jywarren commented 1 year ago

Hi @7malikk this is excellent research. I think it's not surprising that some kind of token or login is required. Otherwise IA could accept uploads from anyone without user login required. gist.github.com used to allow creating a new gist without an account, or if you had an account and were logged in, it'd add it to yours. But I think they had to stop that probably due to spam.

Let's keep brainstorming and researching, but for what it's worth, we could guide people like this perhaps:

### Share by URL

To share a map by URL, you'll need to upload your saved map JSON file somewhere publicly accessible online. The easiest way is to upload the `mapknitter.json` file into the same Archive.org collection as your images. Then when you open that collection in MapKnitter Lite, it will auto-detect your saved map and place images as you had them.

### Share by email

You can also share your saved map file by email. Anyone with the file can drag it onto MapKnitter Lite, and it will fetch and place all the images you've saved. 

What do you think? This doesn't sound too bad if it's clearly presented in a modal, i think. Most folks will have already created an Archive.org collection, right?

7malikk commented 1 year ago

Hi @7malikk this is excellent research. I think it's not surprising that some kind of token or login is required. Otherwise IA could accept uploads from anyone without user login required. gist.github.com used to allow creating a new gist without an account, or if you had an account and were logged in, it'd add it to yours. But I think they had to stop that probably due to spam.

Let's keep brainstorming and researching, but for what it's worth, we could guide people like this perhaps:

Thank you @jywarren, I totally agree, I will keep searching for viable ways to get the files publicly accessible online, maybe not through IA.

What do you think? This doesn't sound too bad if it's clearly presented in a modal, i think. Most folks will have already created an Archive.org collection, right?

These are good, and yes most folks should have already created an IA collection.

If I can not find another solution as to the auto-upload, I would kick off a PR with the latter. Thank you for your input @jywarren

7malikk commented 1 year ago

Hello, @jywarren I have resolved to move forward with the modal.

Although I had an idea inspired by this tool where we have an API to which we send our JSON data in the body of a POST request and it responds with a URL to the hosted JSON data.

A friend and I worked on said API that utilizes MongoDB and Express. It was hosted on render. Here is the post request URL: https://jsonserve.onrender.com/postjson The codebase: https://github.com/Ojerry/jsonserver

I took into consideration amount of requests and storage, and with these, I came to the conclusion that the modal would be a better choice

I do want your opinion though, thank you!

jywarren commented 1 year ago

Hi @7malikk - wow cool i like the postjson idea! Honestly, if it were restricted to JSON as I imagine yours is, I don't feel like it would be a huge target for spam. The main issue is archival storage of the data -- it would be amazing if it were Archive.org-level redundant long-term storage. But that's tough! I think this solution could be great for shorter-term storage of maps, but we can't really guarantee that data would be there longer than a year or so, you know, because services come and go.

I think for now I agree with you that a modal explaining things is a good choice for now. We can link directly to the upload page for Archive.org to make it as smooth as possible. This is also good because even if we add other means of saving later, we could rely on this as a backup plan because we imagine it's a very flexible and stable way to save maps.

OK, sounds good!

7malikk commented 1 year ago

Thank you @jywarren I totally agree.

Here's the current look:

shareMap

I believe it looks good, I am finishing up on it, just one little error I want to resolve before making a PR.

jywarren commented 1 year ago

Looks wonderful. Great work!

On Tue, Jan 31, 2023 at 10:59 AM Malik @.***> wrote:

Thank you @jywarren https://github.com/jywarren I totally agree. Here's the current look:

[image: shareMap] https://user-images.githubusercontent.com/75104021/215811756-8f00ba58-4f18-4442-b169-a594ec267fb7.gif

I believe it looks good, I am finishing up on it, just one little error I want to resolve before making a PR.

— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/issues/1340#issuecomment-1410643155, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6JYIBKLUFHBQNV6WJ7TWVEZGJANCNFSM6AAAAAAUHLOIOQ . You are receiving this because you were mentioned.Message ID: @.***>