Open gomeology opened 1 week ago
@gomeology Pushing code to where? Into ByteStash?
Yes. Im basically requesting a way to push code from the command line. With an API it wouldn't matter if it's windows/nix. You could also implement a way to pull code with an API search of sorts. Maybe using tags.
I'd love to see something like this as well! There are a couple of examples (paste-C), basically you'd wanna pipe a file or some text via curl to the service and get the link in return. Settings can be set via query parameters, and the entire body becomes the content
@scheibling I hadn't considered a use-case like that, good idea! From your perspective, what's the best way this should be implemented? As someone who hasn't used paste-c, I'm not sure of it's intricacies. Is it feasible for you to write out json every time you want to submit a snippet, e.g.:
{
"title": "My Title",
"description": "Some description",
"categories": ["1", "2"],
"fragments": [
{
"file_name": "name.py",
"code": "My code",
"language": "python"
}
]
}
Thoughts? Is there an easier way you can come up with?
I think two or three options might be nice in the long run - post, multipart and json. This could be the same endpoint, but the content type header differentiates between the three (application/octet-stream, multipart/form-data or application/json)
Post would be /upload?filename=abc124&description=Test&tags=taga,tagb
With the file as body
Multipart would include the file, filename in the multipart data and title/description/tags in form fields
And then json, basically like you describe it! That would cover most all of the use cases I can think of (upload via CLI tool, plain curl for quick uploads, from postman or integrated in a piece of software)
I'd be happy to put together an initial PR if you'd like, I have my own CLI toolbox that currently uses paste-C but I've been looking for a good self-hosted alternative and this looks awesome
@scheibling Great ideas, that sounds perfect.
Go ahead! Contributions are always welcome.
With the addition of user accounts this is more complex- we should allow users to create API keys that they can use to push this code to their account. The general idea stays the same, i.e.:
/upload?filename=somefile&description=mydescription&tags=tag1,tag2
Just include authentication:
/upload?filename=somefile&description=mydescription&tags=tag1,tag2&api_key=my-api-key
Maybe also public=true|false, might also need to consider fragments
Api to push code. Not sure how the formatting would work for this one though.