Documentation
¶
Index ¶
- Constants
- func InitS3(bucket string, basePath string, region string, credentialsFile string, ...) error
- type AwsS3
- func (a *AwsS3) CheckFileIsExist(awsFile string) error
- func (a *AwsS3) DeleteFile(awsFile string) error
- func (a *AwsS3) DownloadToFile(awsFile string, localFile string) (int64, error)
- func (a *AwsS3) GetPreSignedURL(method string, awsFile string, expirySeconds int) (string, error)
- func (a *AwsS3) UploadFromFile(localFile string) (string, error)
- func (a *AwsS3) UploadFromReader(reader io.Reader, awsFile string) (string, error)
- func (a *AwsS3) WithBucketAndBasePath(currentBasePath string, currentBucket ...string) *AwsS3
Constants ¶
View Source
const ( // StorageClass 存储类型 StorageClass = "STANDARD_IA" // AccessKeyIDFieldName aws配置文件credentials的访问id字段名称 AccessKeyIDFieldName = "aws_access_key_id" // SecretAccessKeyFieldName aws配置文件credentials的访问密钥字段名称 SecretAccessKeyFieldName = "aws_secret_access_key" // UploadMethod 预签名上传 UploadMethod = "put" // DownloadMethod 预签名下载 DownloadMethod = "get" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AwsS3 ¶
type AwsS3 struct { Bucket string // aws的存储桶 BasePath string // 结尾必须以路径分隔符号/结尾 Region string // 区域 Session *session.Session // 会话 S3 *s3.S3 // s3对象 // contains filtered or unexported fields }
AwsS3 封装aws s3对象
func NewAwsS3 ¶
func NewAwsS3(bucket string, basePath string, region string, credentialsFile string, credentialsValues ...string) (*AwsS3, error)
NewAwsS3 使用初始化s3,建议优先使用.aws/credentials文件,如果不配置文件,可以传递aws_access_key_id和aws_secret_access_key值
func (*AwsS3) CheckFileIsExist ¶
CheckFileIsExist 检查对象是否存在
func (*AwsS3) DownloadToFile ¶
DownloadToFile 从S3下载文件到本地
func (*AwsS3) GetPreSignedURL ¶
GetPreSignedURL 获取访问s3资源的签名url,给第三方上传和下载资源使用
func (*AwsS3) UploadFromFile ¶
UploadFromFile 把文件上传到s3,s3上的文件名和上传的文件名一致
func (*AwsS3) UploadFromReader ¶
UploadFromReader 读取reader内容上传到s3,可以指定以文件名
Click to show internal directories.
Click to hide internal directories.