ali

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunkUpload

func ChunkUpload(prefer, dfsID, bucketType, filePath, fileName string) (bn, endpoint string, err error)

ChunkUpload 文件分块上传 need config: 需要config: "oss": { "chunkSize":5120000,

    "cloud": "aliyun",
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    },
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    }
  },

prefer 如果为空,则取Default dfsID 调用SetMultiPartDfsID或是SetDfsID方法生成 bucketType 如果不传,则表示是data

func ChunkUploadGetStream

func ChunkUploadGetStream(userID, prefer, cloud string, chunk utils.ChunksObj) (utils.ChunksObj, int, string, error)

ChunkUploadGetStream chunk upload for get 400 NotExist client should call post to upload this part 200 OK client need to ignore this part 300 dfsID caller should do other thing, then client can get success upload infor 500 client need to upload whole file again

func ChunkUploadGetStreamCS added in v1.0.6

func ChunkUploadGetStreamCS(userID, prefer, cloud string, chunk utils.ChunksObj) (utils.ChunksObj, int, string, error)

func ChunkUploadGetStreamCSByDfsID added in v1.0.7

func ChunkUploadGetStreamCSByDfsID(userID, dfsID, prefer, cloud string, chunk utils.ChunksObj) (utils.ChunksObj, int, string, error)

func ChunkUploadPostStream

func ChunkUploadPostStream(userID, prefer, cloud string, chunk utils.ChunksObj, fileChunk *multipart.FileHeader) (utils.ChunksObj, int, string, error)

ChunkUploadPostStream chunk upload for post 400 NotExist client should call post to upload this part 200 OK client need to ignore this part 300 dfsID caller should do other thing, then client can get success upload infor 500 client need to upload whole file again

func ChunkUploadPostStreamCS added in v1.0.6

func ChunkUploadPostStreamCS(userID, prefer, cloud string, chunk utils.ChunksObj, fileChunk *multipart.FileHeader) (utils.ChunksObj, int, string, error)

func ChunkUploadPostStreamCSByDfsID added in v1.0.7

func ChunkUploadPostStreamCSByDfsID(userID, dfsID, prefer, cloud string, chunk utils.ChunksObj, fileChunk *multipart.FileHeader) (utils.ChunksObj, int, string, error)

func GetFile

func GetFile(bucketName, dfsID string) ([]byte, string, string, int64, error)

GetFile get file bytes, filename,content-type, size from ali oss

func GetTempDownURLFileName

func GetTempDownURLFileName(bucketName, dfsID string, expires int64) (map[string]string, error)

GetTempDownURLFileName get temp download url from oss return example:

{
	"url":"xxx",
	"fileName":"xxx"
}

func InitBucket

func InitBucket(prefer, bucket string) (*oss.Bucket, error)

InitBucket init bucket connection need config: 需要config:

"oss": {
    "cloud": "aliyun",
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    },
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    }
  },

func PutByteFile

func PutByteFile(prefer, dfsID, bucketType string, chunk utils.ChunksObj, o map[string]string, f []byte) (utils.ChunksObj, error)

PutByteFile 用于字节文件上传 need config: 需要config:

"oss": {
    "cloud": "aliyun",
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    },
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    }
  },

func PutFile

func PutFile(prefer, dfsID, bucketType string, chunk utils.ChunksObj, ossFile *multipart.FileHeader) (utils.ChunksObj, error)

PutFile 文件方式上传 need config: 需要config:

"oss": {
    "cloud": "aliyun",
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    },
    "xxx": {
      "endpoint": "xxx",
      "accessKey": "xxx",
      "accessSecret": "xxx",
  	 "bucket": {
 	    "data": "xxx",
 	    "pub": "xxx"
		  }
    }
  },

Types

type BucketInfo added in v1.0.6

type BucketInfo struct {
	OsBucket map[string]*oss.Bucket
	Lock     sync.Mutex
}

Jump to

Keyboard shortcuts

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