oss

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Example (S3stub)
package main

import (
	"github.com/davecgh/go-spew/spew"
	"github.com/sqjian/go-kit/oss"
)

func main() {
	checkErr := func(err error) {
		if err != nil {
			panic(err)
		}
	}
	stub, err := oss.NewS3Stub(
		"12345678",
		"12345678",
		"http://x.x.x.x:xxxx",
	)
	checkErr(err)

	buckets, err := stub.ListBuckets()
	checkErr(err)
	spew.Dump(buckets)

	for _, bucket := range buckets {
		objs, err := stub.ListObjects(*bucket.Name)
		checkErr(err)
		spew.Printf("bucket:%v,objs:%v", *bucket.Name, objs)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S3Stub

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

func NewS3Stub

func NewS3Stub(accessKey, secretKey, endpoint string) (*S3Stub, error)

func (*S3Stub) BucketExists

func (s *S3Stub) BucketExists(bucketName string) (bool, error)

BucketExists checks whether a bucket exists in the current account.

func (*S3Stub) CopyToFolder

func (s *S3Stub) CopyToFolder(bucketName string, objectKey string, folderName string) error

CopyToFolder copies an object in a bucket to a subfolder in the same bucket.

func (*S3Stub) CreateBucket

func (s *S3Stub) CreateBucket(name string, region string) error

CreateBucket creates a bucket with the specified name in the specified Region.

func (*S3Stub) DeleteBucket

func (s *S3Stub) DeleteBucket(bucketName string) error

DeleteBucket deletes a bucket. The bucket must be empty or an error is returned.

func (*S3Stub) DeleteObjects

func (s *S3Stub) DeleteObjects(bucketName string, objectKeys []string) error

DeleteObjects deletes a list of objects from a bucket.

func (*S3Stub) DownloadFile

func (s *S3Stub) DownloadFile(bucketName string, objectKey string, fileName string) error

DownloadFile gets an object from a bucket and stores it in a local file.

func (*S3Stub) DownloadLargeObject

func (s *S3Stub) DownloadLargeObject(bucketName string, objectKey string) ([]byte, error)

DownloadLargeObject uses a download manager to download an object from a bucket. The download manager gets the data in parts and writes them to a buffer until all the data has been downloaded.

func (*S3Stub) ListBuckets

func (s *S3Stub) ListBuckets() ([]types.Bucket, error)

ListBuckets lists the buckets in the current account.

func (*S3Stub) ListObjects

func (s *S3Stub) ListObjects(bucketName string) ([]types.Object, error)

ListObjects lists the objects in a bucket.

func (*S3Stub) UploadFile

func (s *S3Stub) UploadFile(bucketName string, objectKey string, fileName string) error

UploadFile reads from a file and puts the data into an object in a bucket.

func (*S3Stub) UploadLargeObject

func (s *S3Stub) UploadLargeObject(bucketName string, objectKey string, largeObject []byte) error

UploadLargeObject uses an upload manager to upload data to an object in a bucket. The upload manager breaks large data into parts and uploads the parts concurrently.

Jump to

Keyboard shortcuts

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