Closed buhman closed 8 years ago
85c6fba2aadca7687629e001b4d694aa4ec9617d + 829a40be6e8cd9cb07eab86a455f3aaf82d5e683
worst idea ever; 8046dcb76d6189085d2e328ac6625147309e1106
worst idea ever; 8046dcb
why, out of curiosity, was this approach abandoned? i understand we can just add a suffix to guess the mimetype, but it would be great to have automation on the server-side, or at least a way for clients to provide a mimetype... :) thanks!
This was over 2 years ago; I know about as much as these commits as you do :)
or at least a way for clients to provide a mimetype
There is, actually: https://ptpb.pw/a#header-paste-media-types
Here's how you do it in curl:
λ zack [~] → curl -F 'c=@-;filename=_.png' https://ptpb.pw < foo.jpg
date: 2018-08-25T18:01:14.059523+00:00
digest: 14607bd8db563d47e3ffa57dba0ea0fcd3a167b3
long: ABRge9jbVj1H4_-lfboOoPzToWez
short: oWez
size: 631936
status: created
url: https://ptpb.pw/oWez.png
uuid: 3f6d9dea-6aeb-47c6-9d50-6655c4621759
$ curl -sD- https://ptpb.pw/oWez | grep Content-Type
Content-Type: image/png
By default filename
is the same as the form name value (in this example, -
). IOW if you did:
$ curl -F 'c=foo.jpg' https://ptpb.pw
$ curl -sD- https://ptpb.pw/oWez | grep Content-Type
Content-Type: image/jpeg
..the filename
behavior is implicit. If filename
can be evaluated to a mimetype known to pb, that mimetype gets stored in the paste metadata at creation.
I never actually do any of this, instead I use the per-request (${id}.png
) behavior; it's marginally less work than filename twiddling and better hints to the recipient what is about to be loaded by their browser.
the thing is i'm looking at integration into other pastebin clients (e.g. pastebinit) and one thing they can do is send a mimetype along, so it would be useful to document those things better in the API or somewhere... :)
thanks!
Oh, that's a little different from what this issue was dealing with (magically calculating mimetype by examining the paste body).
pastebinit
I don't understand why a 500 line script is considered desirable for this, especially one so awkwardly written (imports and function definitions wrapped in try/except; NIH'ing six compatibility imports; awkward "params" building).
Anyway, if you want to use this, maybe try json (the alternative is urlencoded, which works only by accident, not as a thing I'm interested in supporting).
This should be something like:
[format]
content = content
[defaults]
post_format = json
eh. i don't like pastebinit much either, but it does have the advantage of talking with many pastebins and providing a unified interface... :) and really, so far I've just used your simple shell script (or just remember the curl magic) instead and i love it...
i will definitely try your suggestion next time i try to fix pastebinit again though, thanks!