Upload images in Go (video tutorial)
Last updated: Sep-04-2025
Overview
Learn how to upload images in Go using the Cloudinary Go SDK.
On this page:
Video tutorial
This video is brought to you by Cloudinary's video player - embed your own!
View the code
You can find the code from this tutorial in GitHub.Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.
Introduction
One of the most important parts of your workflow is getting your images and videos into the Cloudinary Media Library. In this tutorial, you'll learn how to use the Go SDK to upload one or multiple images to Cloudinary. |
Upload a single image from your local file system
Once the Cloudinary Go module is installed, imported, and configured, you can upload local images from your directory. Start by creating a context with context.Background() and save it to the variable ctx . Then call the Cloudinary uploader method, passing the image path as an argument. Make sure to reference the correct path in your file system. Save the upload response in a variable and add proper error handling. Finally, print out the response as formatted JSON for easy reading. |
Upload response
When you run the script, it returns a comprehensive upload response containing metadata and the delivery URL for your image. You can then open the image in a browser window to verify it's delivered correctly from Cloudinary. |
Upload multiple images from your local file system
To upload multiple files efficiently, first define their file paths in an array, then use a Go loop to iterate over this array. Inside the loop, place the Cloudinary uploader code and replace the static image path with the loop variable that represents the current image path. Be sure to add proper error handling to catch any issues during the upload process. This approach ensures each image in the array gets uploaded successfully. For cleaner output, instead of printing the entire upload response for each image, you can log only the secure URLs. |
Upload a single image from a remote URL
While we've covered uploading images from your local directory, Cloudinary's uploader is versatile and accepts images from other sources as well. You can upload images directly from remote URLs, allowing you to pull images from other servers directly into your Cloudinary account. The process is straightforward: simply replace the local image path with a web image URL in your uploader call. When you run the code, it returns the Cloudinary delivery URL for the uploaded image, which you can then open in a browser to verify the successful upload. |
Keep learning
Related topics
- Learn more about uploading images and videos using the Go SDK.
- Take a look at our Upload guide to learn about uploading to Cloudinary in general.
- Use the Upload API reference to find all the options and parameters available.
- Watch more Dev Hints videos on the Cloudinary YouTube channel.
If you like this, you might also like...
Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
✖️