Giter Site home page Giter Site logo

cloudinary-go's People

Contributors

aleksandar-cloudinary avatar asisayag2 avatar bprosnitz avatar const-cloudinary avatar idanl-cloudinary avatar kjarmicki avatar markraymondlush avatar njb90 avatar pamrulla avatar patrick-tolosa avatar suraj3240 avatar udipl avatar yomesinc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudinary-go's Issues

Introduce custom error types

Explain your use case

All the errors from SDK now returns in raw format.
Moreover - they are bubbling up from the very bottom level to the client level.

Describe the problem you’re trying to solve

This errors might be everything - starting from the HTTP errors (can't connect to the server, wrong credentials, smth else) to JSON umarshaling problems.

Does the client really need such verbose level of errors and does he (she) really need to know that we've got some problem during JSON unmarshaling?

Do you have a proposed solution?

NextCursor field in GetTransformationResult not being sent in response.

Bug report for Cloudinary Go SDK

Before proceeding, please update to the latest version and test if the issue persists

Describe the bug in a sentence or two.

NextCursor is not sent in the reponse for admin.GetTransformation()

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

When trying to get the list of derived images from a transform, we do not receive the next_cursor field in the response, so we can never get more derived images after the first call, even with maxResults: 500

	resp, err := cld.Admin.GetTransformation(
		context.TODO(),
		admin.GetTransformationParams{Transformation: t, MaxResults: 1},
	)
	if err != nil {
		fmt.Println(err)
		return nil, err
	}
    fmt.Printf("%+v\n", resp)

that call results in the following (url names have been removed)

&{Name:t_homepage_carousel_card_image AllowedForStrict:true Used:true Named:true Info:[map[crop:fill gravity:face height:390 width:312] map[radius:10]] Derived:[{PublicID:valid/path/1 ResourceType:image Type:upload Format:jpg URL:http://media.validurl SecureURL:https://media.validurl Bytes:11989 ID:xxx}] Error:{Message:}}

There are more than 500 derived images for this transformation, so we will need to be able to paginate these responses.

OS

  • Linux
  • Windows
  • macOS
  • Other (Specify)
  • All

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version - 2.2.0
  • GoLang Version - 1.17.2 darwin/amd64

Promoted fields

The principle I was referring to during our conversation is Promoted fields.
You can use a structure name in constructor to define which fields you are defining now:

Here is your structure:

type CreateUploadPresetParams struct {
	Name             string `json:"name,omitempty"`
	Unsigned         bool   `json:"unsigned,omitempty"`
	DisallowPublicId bool   `json:"disallow_public_id,omitempty"`
	Live             bool   `json:"live,omitempty"`
	uploader.UploadParams
}

And here is instantiation:

	updateUPParams := UpdateUploadPresetParams{
		Name:     UPName,
		Unsigned: false,
		Live:     false,
	}
	updateUPParams.Tags = api.CldApiArray{"go-tag3", "go-tag4"}

You could change it this way:

	updateUPParams := CreateUploadPresetParams{
		Name:         UPName,
		Unsigned: false,
		Live:     false,
		UploadParams: uploader.UploadParams{Tags: api.CldApiArray{"go-tag1", "go-tag2"}},
	}

It might be a little overcomplicated but if you'd give a proper name for such a nested struct or split it to several different structs - it should be ok.

package main

import "fmt"

type Size struct {
	x int
	y int
	z int
}

type Box struct {
	name string
	Size
}

func main() {
	box := Box{name: "New box!", Size: Size{x: 100, y: 200, z: 100}}
	fmt.Printf("Box x size is %v", box.x)
}

Context metadata is unavailable from admin.SearchAsset

Explain your use case

I would like to access the context metadata from an asset after calling (*admin.API).Search.

In my particular use-case, I want to access the alt text of an asset.

Describe the problem you’re trying to solve

The context metadata is not returned as part of a member of the admin.SearchAsset. The only way of getting the data out with the code as-is is by unmarshaling the SearchResult.Response field (which is an interface{}) into a custom data structure, which is error-prone.

Do you have a proposed solution?

The easier way of handling this would be to add a new field called ContextMetadata ContextMetadataResult which contains the metadata context as a map[string]string. This is consistent with the current way other pieces of metadata are returned (e.g., ImageMetadata ImageMetadataResult).

Request params passed in for signing in Upload API request are not filtered in accordance with documentation

Bug report for Cloudinary Go SDK

The Upload API request signing includes all passed parameters to the signing method, despite the documentation clearly states that All parameters added to the method call should be included except: file, cloud_name, resource_type and your api_key.
The server rejects signatures that include one of these values.

This breaks when a ResourceType field is non-empty in in an UploadParams struct for a request; it gets marshaled as resource_type and included in the signature, which doesn't match the server's logic.

See proposed fix #25

Describe the bug in a sentence or two.

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

Enter a ResourceType field that is non-empty in an UploadParams struct for a request, e.g. "video".

OS

  • Linux
  • Windows
  • macOS
  • Other (Specify)
  • All

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version - 1.1.0
  • GoLang Version - 1.15

Repository

If possible, please provide a link to a reproducible repository that showcases the problem

Unable to download a zip archive of multiple files

Describe the bug in a sentence or two.

I try to download multiple images as a zip file. When I try the code below I receive the following error: Missing public_ids.
I contacted Cloudinary support and they verified that the golang code used for this library is not correct.

Issue Type

  • Behaviour - Functions are not working as expected

Steps to reproduce

`
var ids = api.CldAPIArray{}
for _, up := range pr.Uploads {
if up.Format == "jpg" {
ids = append(ids, up.PublicID, up.Format)
}
}

url, err := cl.Upload.DownloadZipURL(uploader.CreateArchiveParams{
    PublicIds:    ids,
    ResourceType: api.Image,
})
if err != nil {
    logrus.Fatal(err)
}

fmt.Println(url)`

OS

  • Linux

Versions and Libraries

  • Cloudinary Go SDK Version - 2.1.0
  • GoLang Version - 1.18.5

Create signed request (signature)

Feature request for Cloudinary Go SDK
…(If your feature is for other SDKs, please request them in the relevant repo)

Explain your use case

  • I need to generate a signature on the backend for the frontend to create a signed request

Describe the problem you’re trying to solve

Do you have a proposed solution?

Signing Parameters overwrites existing timestamp

Following instructions on adding the Media Upload widget

It recommends using the api.SignParameters method to generate an upload signature.

Part of this signature is a timestamp - which is generated in the frontend and needs to match the timestamp used to generate the signature.

However the code inside api.SignParameters will overwrite any existing timestamp given to it.

The result is that sometimes the signature will work (when processed with the same timestamp), and sometimes it won't work (if not processed within the same timestamp period).

This code needs to have a check to ensure that a timestamp doesn't already exist before adding one.

Include step go mod init before go get

Since users are unable to use go get until a go mod has been initialized, is it worth including a pre-requisite line before the

go get github.com/cloudinary/cloudinary-go/v2

something like

go mod init cloudinaryexample.com/m/v2

NextCursor field in DeleteAssetsResult

If I understand the documentation correctly, a delete request could return partial: true and a next_cursor parameter which should be passed to another call to continue the delete operation.

As far as I can tell, the SDK does not return this next_cursor parameter. I think it should be added to the DeleteAssetsResult type.

Custom http.Client or http.RoundTripper

Feature request for Cloudinary Go SDK

Explain your use case

I need to be able to modify the http.RoundTripper or http.Client to add my own tracing/instrumentation.

Do you have a proposed solution?

Expose a way to modify the http.Client.Transport via the Configuration that's passed into the client.

Add Access Control to UploadParams

Describe the bug in a sentence or two.

uploader.UploadParams is missing the optional AccessControl field that is present in the api documentation Api Link

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version - 2.7.0
  • GoLang Version - 1.21.7

Base64file uploading to cloudinary is not working

`

func uploadImageToCloudinary(base64str, name string) (*uploader.UploadResult, error) {
cloudinaryURL := os.Getenv("CLOUDINARY_URL")
cloudinaryClient, err := cloudinary.NewFromURL(cloudinaryURL)
if err != nil {
return nil, err
}
formattedString := fmt.Sprintf("data:image/jpeg;base64,%s", base64str)

uploadParams := uploader.UploadParams{
	PublicID:       name,
	UseFilename:    true,
	UniqueFilename: true,
}

// Upload the Base64 encoded content
result, err := cloudinaryClient.Upload.Upload(context.Background(), formattedString, uploadParams)
if err != nil {
	return nil, err
}

return &result, nil

}

`

I tried to do like this and also I tried many but just not working

Possible incorrect param for a function

Bug report for Cloudinary Go SDK

Before proceeding, please update to the latest version and test if the issue persists

Describe the bug in a sentence or two

func (u *API) UpdateMetadata(ctx context.Context, params RenameParams) (*UpdateMetadataResult, error) {

Takes a RenameParams I would have expected it take type UpdateMetadataParams struct {

Regards

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • [X ] Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

Code search,

Error screenshots

… if applicable

OS

  • Linux
  • Windows
  • macOS
  • Other (Specify)
  • [X ] All

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version -Latest
  • GoLang Version - Latest

Repository

func (u *API) UpdateMetadata(ctx context.Context, params RenameParams) (*UpdateMetadataResult, error) {

cloudinary.NewFromURL does not work for custom domains

Bug report for Cloudinary Go SDK

cloudinary.NewFromURL does not work for custom domains as it returns an instance of cloudinary where further operations return URLs that do not exist.

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

package main

import (
	"context"
	"fmt"
	"github.com/cloudinary/cloudinary-go"
	"log"
)

func main() {
       // fake domain and publicId to showcase the issue
	cld, err := cloudinary.NewFromURL("https://cms.cloudinary.my-domain.com/image/upload/v1623180876/folder-1/folder-2/my-image.png")
	if err != nil {
		log.Fatalf("Failed to intialize Cloudinary, %v", err)
	}

	i, err := cld.Image("folder-1/folder-2/my-image")
	i.Transformation = "w_500"
	myURL, err := i.String()
	fmt.Println(myURL)
}

The above code prints this URL:

https://res.cloudinary.com/cms.cloudinary.my-domain.com/image/upload/w_500/v1/folder-1/folder-2/my-image?_a=AQAK9cJ

which returns 404.

OS

  • Linux
  • Windows
  • macOS
  • Other (Specify)
  • All

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version - v1.7.0
  • GoLang Version - go version go1.18.1 windows/amd64

Getting an error: invalid character '<' looking for beginning of value

Bug report for Cloudinary Go SDK

Before proceeding, please update to the latest version and test if the issue persists

Describe the bug in a sentence or two.

Uploading this 3D model
https://res.cloudinary.com/shirly-dam/image/upload/v1701186432/3d-models/MVILLE_Chill_O_Clock_Singles_Bin.glb
through the SDK results in an error
invalid character '<' looking for beginning of value
but as we can see it is possible to upload it to Cloudinary.

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

… if applicable

Error screenshots

invalid character '<' looking for beginning of value

OS

  • Linux
  • Windows
  • macOS
  • Other (Specify)
  • All

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version - 2.6.0
  • GoLang Version - 1.19

Repository

If possible, please provide a link to a reproducible repository that showcases the problem

Concurrency issue with analytics

Bug report for Cloudinary Go SDK

Before proceeding, please update to the latest version and test if the issue persists

I've looked at the code in this repository and the issue seems to still be there

Describe the bug in a sentence or two.

Analytics doesn't seem to be thread/concurrent safe. I'm not sure if this is deliberate, but seems like it could be an easy fix, since couldn't this initialization happen before the calls to getKey? https://github.com/cloudinary/cloudinary-go/blob/main/asset/analytics.go#L80

We use cloudinary to get images inside a graphql resolver, which means we use the cloudinary instance across threads. This can result in the stack trace below.

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

  1. Create cloudinary instance
  2. Create multiple goroutines which call Image
  3. Occasionally you may get this issue

Error screenshots

"/go/pkg/mod/github.com/cloudinary/[email protected]/asset/asset.go:93 +0x3d8 fp=0xc0002008c8 sp=0xc0002005f0 pc=0xa522f8"
"github.com/cloudinary/cloudinary-go/asset.Asset.String(0xc7f706, 0x5, 0xc80d02, 0x6, 0xc0002df4f0, 0x9, 0x0, 0xc00013e230, 0x46, 0x0, ...)"
"/go/pkg/mod/github.com/cloudinary/[email protected]/asset/asset.go:287 +0x38 fp=0xc0002005f0 sp=0xc000200588 pc=0xa537f8"
"github.com/cloudinary/cloudinary-go/asset.(*Asset).query(0xc0002008c8, 0x6, 0x6)"
"/go/pkg/mod/github.com/cloudinary/[email protected]/asset/analytics.go:29 +0x62 fp=0xc000200588 sp=0xc0002004d8 pc=0xa511a2"
"github.com/cloudinary/cloudinary-go/asset.sdkAnalyticsSignature(0x82, 0x8)"
"/go/pkg/mod/github.com/cloudinary/[email protected]/asset/analytics.go:71 +0x3dd fp=0xc0002004d8 sp=0xc000200408 pc=0xa517fd"
"github.com/cloudinary/cloudinary-go/asset.encodeVersion(0xc7f0ad, 0x5, 0x82, 0x3, 0x4, 0x40)"
"/go/pkg/mod/github.com/cloudinary/[email protected]/asset/analytics.go:80 +0x190 fp=0xc000200408 sp=0xc000200360 pc=0xa51ae0"
"github.com/cloudinary/cloudinary-go/asset.getKey(0xc00013adc0, 0x6, 0x3, 0xc0002ecc30)"
"/usr/local/go/src/runtime/map_faststr.go:291 +0x3fe fp=0xc000200360 sp=0xc0002002f8 pc=0x412e9e"
"runtime.mapassign_faststr(0xb7b5a0, 0xc0000f91a0, 0xc0002df580, 0x6, 0x2)"
"/usr/local/go/src/runtime/panic.go:774 +0x72 fp=0xc0002002f8 sp=0xc0002002c8 pc=0x42dc02"
"runtime.throw(0xc8bb2b, 0x15)"
"goroutine 26 [running]:"
"fatal error: concurrent map writes"

OS

  • Linux
  • Windows
  • macOS
  • Other (Specify)
  • All

Versions and Libraries (fill in the version numbers)

  • Cloudinary Go SDK Version - Issue appears to be in the latest version
  • GoLang Version - 1.19

Repository

If possible, please provide a link to a reproducible repository that showcases the problem

Including Moderation in ExplicitResult (UploadResult).

I want to call "Explicit" method with moderation request for existing media, but I couldn't get the Moderation property in the response type.

res, err := cld.Upload.Explicit(ctx,
		uploader.ExplicitParams{
			PublicID:        publicId,
			Type:            "upload",
			ResourceType:    assetType,
			Moderation:      moderationMethod})
res.Moderation // not exists

I'd be happy if you'll extend "ExplicitResult" to include that.
Tomer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.