Cloud storage using StowUtils package in Golang - Client Libraries | Hire Golang Developer
loader image

Cloud storage using StowUtils package in Golang

The intention of this article is to describe how to store files in cloud storage using the Golang stowutils package.

How does it work?

Implementations are referred to by a kind of string (like s3, google) and an object which provides specific configuration values associated with the implementation (like the S3 region, the credentials, the project ID in case of Google Cloud, etc.)
It uses stow package.
Stow provides implementations for cloud storage services. All providers almost have a similar approach when it comes to storing content files (or items) and are stored in buckets (or containers).
Object storage services are the concept around which the idea of stow is structured. It is made up of three main objects:

  • Location – The Container objects are stored here.
  • Container – Group of Item objects.
  • Item – an individual file.

It should be noted that:

  • Location is like s3 or Google, and each location may have many containers (or storage buckets).
  • A container contains many items ( or files).
  • Containers do not contain other containers.
  • Items must belong to a container.


Import Stowutils and implementations:
First, you import stowutils and any implementations you wish to support:


Features of the Stowutils package:

  1. Get Location
  2. Acquire list of containers
  3. Get Container
  4. Acquire list of Items
  5. Get Item
  6. Upload Item
  7. Read Item
  8. Download Item
  9. Delete Item

Get Location

In order to get a location, you need to know the kind of string and a utils.Config object that contains the required configuration information (such as AccessKey, secretKey, JSON Credentials, projectID, etc). Configuration implementation is specific, and so, you should consult each implementation to see what fields are required for particular kind.
Example: For google cloud storage


Example: For s3 cloud storage


Get list of containers

You can get Container list using the utils.ContainerList function:


Here, prefix is a prefix name of containers.


Get Container

You can get a required container using the utils.GetContainer function:


Here, container_name is a required container name (and hence the container_name should be available)


Get a list of Items

You can get item list using utils.ItemList function:


Here, prefix is the prefix name of items.


Get Item

You can get a particular item using utils.GetItem function:


The item_name mentioned here is a required item name (and hence the item_name should be available)


Upload Item

You can upload an item(file) using utils.UploadItem function:


Into whichever container you want to upload a file, pass that container as parameter. Here, file_path is an uploading file path and file_name is the name of the file, which should be unique. Otherwise, it will override an existing file.


Read Item

You can read the item information using utils.ReadItem function:


Here, g_item is a received item using utils.GetItem


Download Item

Also, you can get the URL of the file using utils.DownloadItem function:



Delete Item

You can delete an item from a container using utils.DeleteItem function as mentioned below:


Pass that container and file_name into the function as a params (the file_name should be available), which contains the file that you want to delete.



The above mentioned are all the features of the Stowutils package, and this article covers the basics of how it can be done, and what are the possibilities with it in Golang. Thus, the Stowutils package can be used to achieve the storing of files in the Cloud Storage. Try it out yourself for a better understanding.


We offer Golang development services for building world-class enterprise apps. We have expertise in building most complex software solutions using Google’s Go language. Chat with us now and hire golang developers within 72 hours.

Turn your vision to magnificent reality With
Our Web and Mobile Solutions
The following two tabs change content below.

Reddy Sai

Young Senior Software Developer having 3+years of experience in Web development, skilled in Golang, Ruby, AngularJS, Ruby on Rails & NodeJS. With a handful of skills, he keeps thriving through all the Edge of Web development to become a perfect back end developer. Besides, this young techie will always buzz up & surprise us with his beautiful Movie collections.

Leave a Reply

Your email address will not be published. Required fields are marked *