This commit is contained in:
asteam
2025-07-15 17:26:44 +03:00
parent 89831894df
commit 1f8637400f
4 changed files with 9 additions and 119 deletions

View File

@@ -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
}