CloudStorage

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

README

English | 简体中文

gitee地址:https://gitee.com/pixelmax/gin-vue-admin

github地址:https://github.com/water-gulugulu/CloudStorage

1. 基本介绍

上传图片,图片裁剪,缩略图等方法,本地上传,接入腾讯云,阿里云,七牛云等第三方对象存储,实现对远程图片的一些操作编辑,以及对存储桶的一些操作。

初始化➡️传入配置➡️调用方法,只需三步,即可完成整个操作

2. 目录结构

    ├─server  	     (后端文件夹)
    │  ├─api            (API)
    │  ├─config         (配置包)
    │  ├─core  	        (內核)
    │  ├─docs  	        (swagger文档目录)
    │  ├─global         (全局对象)
    │  ├─initialiaze    (初始化)
    │  ├─middleware     (中间件)
    │  ├─model          (结构体层)
    │  ├─resource       (资源)
    │  ├─router         (路由)
    │  ├─service         (服务)
    │  └─utils	        (公共功能)
    └─web            (前端文件)
        ├─public        (发布模板)
        └─src           (源码包)
            ├─api       (向后台发送ajax的封装层)
            ├─assets	(静态文件)
            ├─components(组件)
            ├─router	(前端路由)
            ├─store     (vuex 状态管理仓)
            ├─style     (通用样式文件)
            ├─utils     (前端工具库)
            └─view      (前端页面)

```学视频。如果觉得项目对您有所帮助可以添加我的个人微信:shouzi_1994,欢迎您提出宝贵的需求。

### 微信交流群
| 微信 |
|  :---:  | 
| <img width="150" src="http://qmplusimg.henrongyi.top/qrjjz.png"> 

添加微信,备注"加入gin-vue-admin交流群"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MD5V

func MD5V(str []byte) string

Types

type Local

type Local struct {
	Path string `mapstructure:"path" json:"path" yaml:"path"` // 本地文件路径
}

func (*Local) ClipFile

func (l *Local) ClipFile(filename string, wi, hi, x0, y0, x1, y1, quality int) (Path, FileName string, err error)

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @function: ClipFile @description: 图片裁剪 @param: filename string 要裁剪的文件名,会和Local.Path拼接组成文件名 @param: wi int 裁剪宽度,传0则默认裁剪宽度 如原图宽为100px x0:10 x1:90 那么成图宽为x1-x0=80px @param: hi int 裁剪高度,传0则默认裁剪高度 如原图高为100px y0:10 y1:90 那么成图高为y1-y0=80px @param: x0 int 裁剪宽坐标,从多少像素开始裁剪,如原图100px x0:10那么从10像素开始裁剪 @param: y0 int 裁剪高坐标,从多少像素开始裁剪,如原图100px y0:10那么从10像素开始裁剪 @param: x1 int 裁剪宽坐标,从x0开始到x1像素裁剪结束,如原图100px x0:10,x1:30那么从10像素开始裁剪到40像素结束 @param: y1 int 裁剪高坐标,从y0开始到y1像素裁剪结束,如原图100px y0:10,y1:30那么从10像素开始裁剪到40像素结束 @param: quality int 像素精度 百分比 @return: Path string 文件访问路径(带文件名) @return: FileName string 文件名 @return: err error 错误信息

func (*Local) DeleteFile

func (l *Local) DeleteFile(key string) error

@author: [wulala](https://github.com/water-gulugulu) @object: *LocalUpload @function: DeleteFile @description: 删除文件 @param: key string @return: error

func (*Local) UploadFile

func (l *Local) UploadFile(file *multipart.FileHeader) (Path, FileName string, err error)

@author: [wulala](https://github.com/water-gulugulu) @object: *LocalUpload @function: UploadFile @description: 上传文件 @param: file *multipart.FileHeader @return: Path string @return: FileName string @return: err error

type LocalOSS

type LocalOSS interface {
	UploadFile(file *multipart.FileHeader) (path, filename string, err error)
	DeleteFile(key string) error
	ClipFile(filename string, wi, hi, x0, y0, x1, y1, quality int) (Path, FileName string, err error)
}

本地上传

func NewLocalOSS

func NewLocalOSS(c *Local) LocalOSS

实例本地上传

type TencentCOS

type TencentCOS struct {
	Bucket     string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`               // 桶名称
	Region     string `mapstructure:"region" json:"region" yaml:"region"`               // 地区
	SecretID   string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"`       // 密钥 id
	SecretKey  string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`    // 密钥key
	BaseURL    string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"`          // 地址
	PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"` // 路径前缀
	// contains filtered or unexported fields
}

TencentCOS config

func (*TencentCOS) DeleteFile

func (t *TencentCOS) DeleteFile(key string) error

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: DeleteFile @description: 删除Bucket里面对应key的文件 @param: key string 文件名 @return: error

func (*TencentCOS) GetBucketACL

func (t *TencentCOS) GetBucketACL() (Acl []cos.ACLGrant, err error)

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: GetBucketACL @description: 获取ACL访问控制列表 @return: Acl []cos.ACLGrant 获取到的ACL列表 @return: err error

func (*TencentCOS) GetBucketAccelerate

func (t *TencentCOS) GetBucketAccelerate() (result *cos.BucketGetAccelerateResult, err error)

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: GetBucketAccelerate @description: 获取存储桶的全球加速状态 @return: result *cos.BucketGetAccelerateResult COS返回的内容 @return: err error

func (*TencentCOS) GetBucketList

func (t *TencentCOS) GetBucketList() (buckets []cos.Bucket, err error)

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: GetBucketList @description: 获取当前区域所有的bucket @return: buckets []cos.Bucket 获取到的bucket列表 @return: err error

func (*TencentCOS) NewClient

func (t *TencentCOS) NewClient() *cos.Client

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: NewClient @description: 初始化COS链接 @param: 必须先初始化TencentCOS传入对应的配置参数 @return: *cos.Client COS链接

func (*TencentCOS) PutBucketAccelerate

func (t *TencentCOS) PutBucketAccelerate(status string) error

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: PutBucketAccelerate @description: 启用或者暂停存储桶的全球加速 @param: status string 枚举值:Suspended、Enabled @return: err error

func (*TencentCOS) UploadFile

func (t *TencentCOS) UploadFile(file *multipart.FileHeader) (path, filename string, err error)

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @object: *TencentCOS @function: UploadFile @description: 删除Bucket里面对应key的文件 @param: file *multipart.FileHeader 文件流 @return: path string 文件访问地址 @return: filename string 文件名 @return: err error

type TencentOSS

type TencentOSS interface {
	UploadFile(file *multipart.FileHeader) (path, filename string, err error) // Upload File to Tencent COS
	DeleteFile(key string) error                                              // Delete Tencent COS File
	GetBucketList() (buckets []cos.Bucket, err error)                         // GET Local Region All Bucket
	GetBucketACL() (Acl []cos.ACLGrant, err error)                            // GET Bucket ACL List
	GetBucketAccelerate() (result *cos.BucketGetAccelerateResult, err error)  // GET Bucket Accelerate
	PutBucketAccelerate(status string) error                                  // PUT Bucket Accelerate
}

TencentOSS interface

func NewTencentOSS

func NewTencentOSS(c *TencentCOS) TencentOSS

@author: [wulala](https://github.com/water-gulugulu) @author: [wulala](https://gitee.com/diunigedaxigua) @function: NewTencentOSS @description: 实现COS接口 @param: c TencentCOS 初始化COS接口参数 @return: TencentOSS

Jump to

Keyboard shortcuts

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