Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kometen/http_post
Simple REST upload that accepts a jpeg file and convert it to heic format.
https://github.com/kometen/http_post
curl golang heic heif jpeg rest-api
Last synced: 1 day ago
JSON representation
Simple REST upload that accepts a jpeg file and convert it to heic format.
- Host: GitHub
- URL: https://github.com/kometen/http_post
- Owner: kometen
- Created: 2017-06-27T23:03:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-27T10:52:41.000Z (over 2 years ago)
- Last Synced: 2024-06-21T18:51:26.167Z (7 months ago)
- Topics: curl, golang, heic, heif, jpeg, rest-api
- Language: Go
- Size: 8.79 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# http_post
Simple REST upload that accepts a jpeg file and convert it to heic format.Writing REST in go is surprisingly simple. The upload part is almost entirely based
on https://github.com/golang-samples/http/blob/master/fileupload/main.go.The conversion part is taken from
http://jpgtoheif.com/ and this is written by Ben Gotow (https://github.com/bengotow).StackOverflow is very handy when I need help writing json at https://stackoverflow.com/a/24356483/319826.
Example converting file to heic format using curl. Open a Terminal window and copy and paste the command
below, change the filename after the @-sign.```
curl -OLJs -F "file=@_7D_8286.JPG" "http://46.101.99.187:8080/upload"
```If the file is located in the Pictures-folder and is called IMG_0906.JPG the command is
```
curl -OLJs -F "file=@Pictures/IMG_0906.JPG" "http://46.101.99.187:8080/upload"
```If you have more than one file the following loop works (in bash and zsh):
```
for f in *.jpg; do
echo ${f}
curl -OLJs -F "file=@${f}" "http://46.101.99.187:8080/upload"
done
```O tells curl to download the file, otherwise it will just display it at the command line.
L tells curl to follow redirects.
J tells curl to save the file using the remote header name.
s tells curl to be silent.
F tells curl what file you want to upload.Give it a minute or two after the file have been uploaded. When it is uploaded and converted a http redirect 303
GET's the converted file with the same name as the original but with the heic extension.The converter also handles png-files.