v1.11.6
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
// UploadImageFileResponse struct to enable image
|
||||
type UploadImageFileResponse struct {
|
||||
// ImageFileUri
|
||||
ImageFileUri string `json:"image_file_uri"`
|
||||
}
|
||||
|
||||
// UploadImageFile uploads file image to platform
|
||||
func (i Image) UploadImageFile(ctx context.Context, filePath string) (string, error) {
|
||||
file, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("can not read file %v", err)
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/uploadImageFile"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
result := UploadImageFileResponse{}
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result.ImageFileUri, nil
|
||||
}
|
||||
Reference in New Issue
Block a user