obs

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

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package obs provides a Huawei Cloud OBS (S3-compatible) Store implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint        string
	Region          string
	AccessKeyID     string
	AccessKeySecret string
	BucketName      string
	ProxyDomain     string // optional proxy domain for public access
}

Config holds Huawei Cloud OBS storage configuration.

type Store

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

Store implements stores.Store backed by Huawei Cloud OBS.

func New

func New(cfg Config) *Store

New creates an OBS-backed store from the given config.

func (*Store) AbortMultipartUpload

func (s *Store) AbortMultipartUpload(bucket, key, uploadID string) error

AbortMultipartUpload cancels a multipart upload.

func (*Store) CompleteMultipartUpload

func (s *Store) CompleteMultipartUpload(bucket, key string, req *stores.CompleteMultipartUploadRequest) (*stores.CompleteMultipartUploadResponse, error)

CompleteMultipartUpload finalizes a multipart upload.

func (*Store) CopyFile

func (s *Store) CopyFile(req *stores.CopyObjectRequest) error

CopyFile copies an object within or across OBS buckets.

func (*Store) CreateBucket

func (s *Store) CreateBucket(req *stores.CreateBucketRequest) error

CreateBucket creates a new OBS bucket. Unlike S3, OBS does not use LocationConstraint via CreateBucketConfiguration — the bucket is created on the configured endpoint.

func (*Store) Delete

func (s *Store) Delete(key string) error

Delete deletes a file from OBS.

func (*Store) DeleteBucket

func (s *Store) DeleteBucket(bucket string) error

DeleteBucket deletes an empty OBS bucket.

func (*Store) DeleteFile

func (s *Store) DeleteFile(bucket, key string) error

DeleteFile deletes an object from an OBS bucket.

func (*Store) Exists

func (s *Store) Exists(key string) (bool, error)

Exists checks if a file exists in OBS.

func (*Store) GetAPIRequestStats

func (s *Store) GetAPIRequestStats(req *stores.APIStatsRequest) (*stores.APIStatsResponse, error)

GetAPIRequestStats returns API request statistics. Huawei Cloud OBS does not expose granular API request metrics via the standard SDK; this returns ErrStatsUnsupported.

func (*Store) GetBucketDomains

func (s *Store) GetBucketDomains(bucket string) ([]string, error)

GetBucketDomains returns the domain names associated with an OBS bucket. For OBS, this returns the proxy domain if configured, otherwise the default endpoint-based domain.

func (*Store) GetBucketInfo

func (s *Store) GetBucketInfo(bucket string) (*stores.BucketInfo, error)

GetBucketInfo returns metadata about an OBS bucket.

func (*Store) GetBucketStats

func (s *Store) GetBucketStats(bucket string) (*stores.BucketStats, error)

GetBucketStats computes the total storage size and object count for an OBS bucket by paginating ListObjectsV2.

func (*Store) GetCDNStats

func (s *Store) GetCDNStats(req *stores.CDNStatsRequest) (*stores.CDNStatsResponse, error)

GetCDNStats returns CDN statistics from the Huawei Cloud CDN API.

func (*Store) GetFileInfo

func (s *Store) GetFileInfo(bucket, key string) (*stores.FileInfo, error)

GetFileInfo returns metadata for a single OBS object.

func (*Store) GetFileURL

func (s *Store) GetFileURL(bucket, key string, expires time.Duration) (string, error)

GetFileURL returns an expiring URL for an OBS object.

func (*Store) GetOriginFetchStats

func (s *Store) GetOriginFetchStats(req *stores.OriginStatsRequest) (*stores.OriginStatsResponse, error)

GetOriginFetchStats returns origin-fetch statistics from the Huawei Cloud CDN API (ShowDomainStats with bs_flux and bs_num metrics).

func (*Store) InitiateMultipartUpload

func (s *Store) InitiateMultipartUpload(bucket string, req *stores.InitiateMultipartUploadRequest) (*stores.InitiateMultipartUploadResponse, error)

InitiateMultipartUpload starts a multipart upload.

func (*Store) ListBuckets

ListBuckets lists all OBS buckets.

func (*Store) ListFiles

func (s *Store) ListFiles(bucket string, req *stores.ListFilesRequest) (*stores.ListFilesResponse, error)

ListFiles lists objects in an OBS bucket.

func (*Store) ListParts

func (s *Store) ListParts(bucket, key string, req *stores.ListPartsRequest) (*stores.ListPartsResponse, error)

ListParts lists the parts of a multipart upload.

func (*Store) MoveFile

func (s *Store) MoveFile(req *stores.CopyObjectRequest) error

MoveFile moves an object within or across OBS buckets.

func (*Store) PresignUpload

func (s *Store) PresignUpload(key, contentType string, expires time.Duration) (*stores.DirectUpload, error)

PresignUpload implements stores.DirectUploadPresigner via a presigned PUT.

func (*Store) PublicURL

func (s *Store) PublicURL(key string) string

PublicURL returns the public URL for a file in OBS.

func (*Store) Read

func (s *Store) Read(key string) (io.ReadCloser, int64, error)

Read reads a file from OBS.

func (*Store) SetBucketPrivate

func (s *Store) SetBucketPrivate(bucket string, isPrivate bool) error

SetBucketPrivate sets the ACL of an OBS bucket.

func (*Store) SignedURL

func (s *Store) SignedURL(key string, expires time.Duration) (string, error)

SignedURL implements stores.PrivateURLSigner via a presigned GET.

func (*Store) UploadFile

func (s *Store) UploadFile(bucket, key string, reader io.Reader, size int64) error

UploadFile uploads data to an OBS bucket.

func (*Store) UploadPart

func (s *Store) UploadPart(bucket, key string, req *stores.UploadPartRequest) (*stores.UploadPartResponse, error)

UploadPart uploads a single part of a multipart upload.

func (*Store) Write

func (s *Store) Write(key string, r io.Reader) error

Write writes a file to OBS.

Jump to

Keyboard shortcuts

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