Giter Site home page Giter Site logo

uploadcare-go's Introduction

uploadcare-go

FOSSA Status

Go library for accessing Uploadcard API https://uploadcare.com/

You are viewing the source code of the upcoming v0.1.0.
This release is still in progress.

Table of Contents

Requirements

go1.13

Installation

To install the library simply run:

go get -u -v github.com/uploadcare/uploadcare-go/...

Documentation

For details on all the functionality in this library, see the GoDoc documentation. Below are a few usage examples.

import(
	"github.com/uploadcare/uploadcare-go/ucare"
	"github.com/uploadcare/uploadcare-go/file"
)

Getting a paginated list of files:

	// your project credentials
	creds := ucare.APICreds{
		SecretKey: "your-project-secret-key",
		PublicKey: "your-project-public-key",
	}

	// client configuration
	conf := &ucare.Config{
		SignBasedAuthentication: true,
	}

	// creating underlying client for API calls and authentication
	client, err := ucare.NewClient(creds, conf)
	if err != nil {
		log.Fatal("creating uploadcare API client: %s", err)
	}

	// creating a file operations service
	fileSvc := file.NewService(client) 

	listParams := &file.ListParams{
		Stored:   ucare.String(true),
		OrderBy: ucare.String(file.OrderBySizeAsc),
	}
	
	fileList, err := fileSvc.List(context.Background(), listParams)
	if err != nil {
		// handle error
	}
			
	// getting IDs for the first 100 files
	ids := make([]string, 0, 100)
	for fileList.Next() {
		finfo, err :=  fileList.ReadResult()
		if err != nil {
			// handle error
		}

		ids = append(ids, finfo.ID)
	}

Acquiring file-specific info:

	fileID := ids[0]
	file, err := fileSvc.Info(context.Background(), fileID)
	if err != nil {
		// handle error
	}

	if file.IsImage {
		h := file.ImageInfo.Height
		w := file.ImageInfo.Width
		fmt.Printf("image size: %dx%d\n", h, w)
	}

License

FOSSA Status

uploadcare-go's People

Contributors

fossabot avatar

Watchers

 avatar  avatar

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.