start using new upload api
This commit is contained in:
parent
46e0ad988b
commit
8c6ef9c3cc
@ -23,7 +23,12 @@ type UploadCommand struct {
|
||||
}
|
||||
|
||||
type UploadError struct {
|
||||
Error string
|
||||
Error string `json:"error"`
|
||||
Status string `json:"string"`
|
||||
}
|
||||
|
||||
type UploadCreate struct {
|
||||
UploadId string `json:"upload_id"`
|
||||
}
|
||||
|
||||
type UploadFileRequest struct {
|
||||
@ -177,11 +182,22 @@ func (c *UploadCommand) FileUpload(sum string) error {
|
||||
}
|
||||
|
||||
func (c *UploadCommand) Execute(args []string) error {
|
||||
sum, err := c.FileExists()
|
||||
cli := c.Cli()
|
||||
resp, err := cli.R().SetError(&UploadError{}).SetResult(&UploadCreate{}).Post("/upload/create")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.FileUpload(sum)
|
||||
|
||||
if err, ok := resp.Error().(*UploadError); ok {
|
||||
logger.Println(string(resp.Body()))
|
||||
logger.Println(resp.Error(), resp.StatusCode(), resp.Header())
|
||||
return errors.New(err.Error)
|
||||
}
|
||||
|
||||
result := resp.Result().(*UploadCreate)
|
||||
fmt.Printf("Upload create: %s", result.UploadId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user