token

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

Why is there this JWTS

In a certain company, due to the previous integration of OSS direct transmission, but when migrating to Google, the direct transmission function was not found yet. Therefore, we decided to write our own interface to provide the client with direct transmission

Method List

BuildToken(aud, disk, bucket string) (*TokenResponse, error)
ParseToken(token string) (*FlysystemClaims, error)
WithTokenUploadMultipart(fs *flysystem.Flysystem, token, fileName string, file *multipart.FileHeader) (*Response, error) 
WithTokenUploadReader(fs *flysystem.Flysystem, token, fileName string, reader io.Reader) (*Response, error)
WithTokenUploadFilePath(fs *flysystem.Flysystem, token, fileName, filePath string) (*Response, error)
WithTokenUploadBase64(fs *flysystem.Flysystem, token, fileName, base64 string) (*Response, error)
WithTokenDelete(fs *flysystem.Flysystem, token, fileName string) (*Response, error)
Delete(fs *flysystem.Flysystem, disk, bucket, fileName string) (*Response, error) 
UploadBase64(fs *flysystem.Flysystem, disk, bucket, fileName, base64Str string) (*Response, error)
UploadReader(fs *flysystem.Flysystem, disk, bucket, fileName string, reader io.Reader) (*Response, error)
UploadByte(fs *flysystem.Flysystem, disk, bucket, fileName string, contents []byte) (*Response, error) 

Code message

code Message
203 Token is empty
403 Token parsing failed
411 file.Open()
305 Driver not found
204 Write error
412 Base64 parsing failed
404 gfs.Delete err

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileUploadError

type FileUploadError struct {
	Code int
	Msg  string
}

func NewError

func NewError(code int, msg string) *FileUploadError

func (*FileUploadError) Error

func (f *FileUploadError) Error() string

type FlysystemClaims

type FlysystemClaims struct {
	jwt.StandardClaims
	Disk   string `json:"disk"`
	Bucket string `json:"bucket"`
}

type JWTToken

type JWTToken struct {
	Key       string
	ExpiresIn time.Duration
}

func (*JWTToken) BuildToken

func (t *JWTToken) BuildToken(aud, disk, bucket string) (*TokenResponse, error)

func (*JWTToken) Delete added in v0.4.1

func (t *JWTToken) Delete(fs *flysystem.Flysystem, disk, bucket, fileName string) (*Response, error)

func (*JWTToken) ParseToken

func (t *JWTToken) ParseToken(token string) (*FlysystemClaims, error)

func (*JWTToken) UploadBase64

func (t *JWTToken) UploadBase64(fs *flysystem.Flysystem, disk, bucket, fileName, base64Str string) (*Response, error)

func (*JWTToken) UploadByte

func (t *JWTToken) UploadByte(fs *flysystem.Flysystem, disk, bucket, fileName string, contents []byte) (*Response, error)

func (*JWTToken) UploadReader

func (t *JWTToken) UploadReader(fs *flysystem.Flysystem, disk, bucket, fileName string, reader io.Reader) (*Response, error)

func (*JWTToken) WithTokenDelete added in v0.4.1

func (t *JWTToken) WithTokenDelete(fs *flysystem.Flysystem, token, fileName string) (*Response, error)

func (*JWTToken) WithTokenUploadBase64

func (t *JWTToken) WithTokenUploadBase64(fs *flysystem.Flysystem, token, fileName, base64 string) (*Response, error)

func (*JWTToken) WithTokenUploadFilePath

func (t *JWTToken) WithTokenUploadFilePath(fs *flysystem.Flysystem, token, fileName, filePath string) (*Response, error)

func (*JWTToken) WithTokenUploadMultipart

func (t *JWTToken) WithTokenUploadMultipart(fs *flysystem.Flysystem, token, fileName string, file *multipart.FileHeader) (*Response, error)

func (*JWTToken) WithTokenUploadReader

func (t *JWTToken) WithTokenUploadReader(fs *flysystem.Flysystem, token, fileName string, reader io.Reader) (*Response, error)

type Manage added in v0.4.1

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

func NewManage added in v0.4.1

func NewManage(token *JWTToken, flysystem *flysystem.Flysystem) *Manage

func (*Manage) BuildToken added in v0.4.1

func (t *Manage) BuildToken(aud, disk, bucket string) (*TokenResponse, error)

func (*Manage) Delete added in v0.4.1

func (t *Manage) Delete(disk, bucket, fileName string) (*Response, error)

func (*Manage) ParseToken added in v0.4.1

func (t *Manage) ParseToken(token string) (*FlysystemClaims, error)

func (*Manage) UploadBase64 added in v0.4.1

func (t *Manage) UploadBase64(disk, bucket, fileName, base64Str string) (*Response, error)

func (*Manage) UploadByte added in v0.4.1

func (t *Manage) UploadByte(disk, bucket, fileName string, contents []byte) (*Response, error)

func (*Manage) UploadReader added in v0.4.1

func (t *Manage) UploadReader(disk, bucket, fileName string, reader io.Reader) (*Response, error)

func (*Manage) WithTokenDelete added in v0.4.1

func (t *Manage) WithTokenDelete(token, fileName string) (*Response, error)

func (*Manage) WithTokenUploadBase64 added in v0.4.1

func (t *Manage) WithTokenUploadBase64(token, fileName, base64 string) (*Response, error)

func (*Manage) WithTokenUploadFilePath added in v0.4.1

func (t *Manage) WithTokenUploadFilePath(token, fileName, filePath string) (*Response, error)

func (*Manage) WithTokenUploadMultipart added in v0.4.1

func (t *Manage) WithTokenUploadMultipart(token, fileName string, file *multipart.FileHeader) (*Response, error)

func (*Manage) WithTokenUploadReader added in v0.4.1

func (t *Manage) WithTokenUploadReader(token, fileName string, reader io.Reader) (*Response, error)

type Response added in v0.4.1

type Response struct {
	Disk   string `json:"disk" xml:"Disk"`
	Bucket string `json:"bucket" xml:"Bucket"`
	Object string `json:"object" xml:"Object"`
}

type TokenResponse

type TokenResponse struct {
	Token    string  `json:"token" xml:"Token"`
	ExpTime  int64   `json:"exp_time" xml:"ExpTime"`
	ExpireIn float64 `json:"expire_in" xml:"ExpireIn"`
}

Jump to

Keyboard shortcuts

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