Skip to content

Commit

Permalink
Partial solution to #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Tihomirov committed Jan 4, 2017
1 parent 206f5b7 commit 401675e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/gowo/cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"log"
"os"

humanize "github.com/dustin/go-humanize"
"github.com/spf13/cobra"

"fmt"
Expand All @@ -47,6 +48,13 @@ var uploadCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
stat, err := file.Stat()
if err != nil {
log.Fatal(err)
}
if stat.Size() > owo.FileUploadLimit {
log.Fatal(fmt.Errorf("[pre-flight] File '%s' exceeds upload limit (%s > %s)", file.Name(), humanize.Bytes(uint64(stat.Size())), humanize.Bytes(owo.FileUploadLimit)))
}
files[idx] = owo.NamedReader{file, arg}
defer file.Close()
}
Expand Down
2 changes: 2 additions & 0 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ package owo
// APIRoot defines base url for the service's API endpoints
const APIRoot = "https://api.awau.moe"

const FileUploadLimit = 83886080

var (
// APIFileUploadURL to send POSTs with files to
APIFileUploadURL = APIRoot + "/upload/pomf"
Expand Down

0 comments on commit 401675e

Please sign in to comment.