Skip to content

Simple REST upload that accepts a jpeg file and convert it to heic format.

Notifications You must be signed in to change notification settings

kometen/http_post

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

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.

About

Simple REST upload that accepts a jpeg file and convert it to heic format.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages