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 }