Help us shape the future of Go! Take the 2026 Go Developer Survey

s3urlupload

package module
v0.0.0-...-bd748db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2016 License: MIT Imports: 6 Imported by: 0

README

s3-url-upload

Concurrently upload files to S3 from URLs using Golang

Start using it

  1. Download and install it:
$ go get github.com/ivancevich/s3-url-upload
  1. Import it in your code:
import "github.com/ivancevich/s3-url-upload"

Example

package main

import (
	"fmt"
	"strings"
	"github.com/ivancevich/s3-url-upload"
)

func main() {
	media := []string{
		"http://www.eventelectronics.com/images/2020-gallery-001.jpg",
		"http://www.eventelectronics.com/images/2020-gallery-002.jpg",
		"http://www.eventelectronics.com/images/2020-gallery-003.jpg",
		"http://www.eventelectronics.com/images/2020-gallery-004.jpg",
	}

	config := s3urlupload.Config{
		AwsAccessKey:  "{AWS_ACCESS_KEY}",
		AwsSecretKey:  "{AWS_SECRET_KEY}",
		AwsS3Endpoint: "{AWS_S3_ENDPOINT}", // e.g. "s3-us-west-2.amazonaws.com"
		AwsS3Bucket:   "{AWS_S3_BUCKET}",
		Workers:       4,
		GetFilePath: func(url string) string {
			parts := strings.Split(url, "/")
			return "eventelectronics/" + parts[len(parts)-1]
		},
	}

	s3UrlUpload := s3urlupload.Init(config)
	results := s3UrlUpload.Run(media...)

	for r := range results {
		fmt.Printf("%+v\n", r)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AwsAccessKey  string
	AwsSecretKey  string
	AwsS3Endpoint string
	AwsS3Bucket   string
	Workers       uint
	GetFilePath   func(string) string
}

type Result

type Result struct {
	URL   string
	Error error
}

type S3UrlUpload

type S3UrlUpload struct {
	// contains filtered or unexported fields
}

func Init

func Init(c Config) *S3UrlUpload

func (*S3UrlUpload) Run

func (s3uu *S3UrlUpload) Run(files ...string) <-chan Result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL