Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudinary.NewFromURL does not work for custom domains #58

Closed
2 of 10 tasks
xorxsan opened this issue May 13, 2022 · 3 comments
Closed
2 of 10 tasks

cloudinary.NewFromURL does not work for custom domains #58

xorxsan opened this issue May 13, 2022 · 3 comments

Comments

@xorxsan
Copy link

xorxsan commented May 13, 2022

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
@tommyg-cld
Copy link

Hi,

You should pass CLOUDINARY_URL to cloudinary.NewFromURL("") which initialises your Go environment with the correct credentials to talk to our API. This URL can be found in your Dashboard.

If you are trying to set up a custom domain for your images, then you should add a secure_cname parameter to your CLOUDINARY_URL.

So e.g.

cld, err := cloudinary.NewFromURL("cloudinary://<api_key>:<api_secret>@<cloud_name>?secure_cname=my.cname.com")

Hope this helps.
Thanks

@xorxsan
Copy link
Author

xorxsan commented May 13, 2022

Oh, thanks for the response. It was not clear from the documentation what the format was. Could you update the documentation and give this example?
Thanks!

@wissam-khalili
Copy link

Happy to see that it was helpful.
I will ask to update the documentation with the following examples as well.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants