Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { SetToken func(string) EnterAuthorization func() string // contains filtered or unexported fields }
Manager is the object that manages Google Drive's credentials, authentication, config, token, etc.
func New ¶
func New(ctx context.Context, path []string, token string, setToken func(token string), enterAuthorization func() string) (*Manager, error)
New creates a new Google Drive "Manager", it's the object that manages authentication, authorization tokens, configs and communication with GoogleDrive.
All files are create within the fixed given `path` (list of strings).
A previously saved authorization `token` can be passed to reuse authorization. If none are available simply pass an empty string here, and a new authorization will be requested.
It requires the following callbacks to be defined:
- setToken: if the token that gives temporary permission to access Google Drive is updated, this function is called. This token can be saved re-used later on, by passing it in the `token` parameter. If nil, it won't be called, and the token will be "forgotten" at the next instance of the program.
- enterAuthorization: when a new token is required, the Manager will open the browser with Google to ask for a renewed authentication. Then it will call this function to have a UI for the user to paste the authorization string given by Google.
May return an error if application credentials are wrong.
type QiNiuManager ¶
QiNiuManager 七牛云存储管理器
func NewQiNiu ¶
func NewQiNiu(accesskey string, secretKey string, bucket string) (*QiNiuManager, error)
NewQiNiu 创建七牛云管理对象
func (*QiNiuManager) QiNiuShareImage ¶
func (qiNiuManager *QiNiuManager) QiNiuShareImage(filename string, img image.Image) error
QiNiuShareImage 将图片发送到七牛云上,需要传入图片名图片内容,目前仅支持网络浏览友好的png后期有需要可以扩展 Beta版本仅支持上传华东地区,其他地区上传有点慢,杭州或者上海这边的上传速度会快一些