Documentation ¶
Overview ¶
Copyright 2023 KubeAGI. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- type ChunkUploader
- type ChunkUploaderConf
- type ChunkUploaderOption
- func WithAnnotations(annotations map[string]string) ChunkUploaderOption
- func WithBucket(bucket string) ChunkUploaderOption
- func WithBucketPath(relativeDir string) ChunkUploaderOption
- func WithFileName(fileName string) ChunkUploaderOption
- func WithMD5(md5 string) ChunkUploaderOption
- func WithPartNumber(partNumber string) ChunkUploaderOption
- func WithUploadID(uploadID string) ChunkUploaderOption
- type Datasource
- type Local
- func (local *Local) GetTags(ctx context.Context, info any) (map[string]string, error)
- func (local *Local) ListObjects(ctx context.Context, source string, info any) (any, error)
- func (local *Local) ReadFile(ctx context.Context, info any) (io.ReadCloser, error)
- func (local *Local) Remove(ctx context.Context, info any) error
- func (local *Local) Stat(ctx context.Context, options any) (err error)
- func (local *Local) StatFile(ctx context.Context, info any) (any, error)
- type OSS
- func (oss *OSS) Abort(ctx context.Context, options ...ChunkUploaderOption) error
- func (oss *OSS) Complete(ctx context.Context, options ...ChunkUploaderOption) error
- func (oss *OSS) CompletedChunks(ctx context.Context, options ...ChunkUploaderOption) (any, error)
- func (oss *OSS) GenMultipartSignedURL(ctx context.Context, options ...ChunkUploaderOption) (string, error)
- func (oss *OSS) GetTags(ctx context.Context, info any) (map[string]string, error)
- func (oss *OSS) IncompleteUpload(ctx context.Context, options ...ChunkUploaderOption) (string, error)
- func (oss *OSS) ListObjects(ctx context.Context, bucketName string, info any) (any, error)
- func (oss *OSS) NewMultipartIdentifier(ctx context.Context, options ...ChunkUploaderOption) (string, error)
- func (oss *OSS) ReadFile(ctx context.Context, info any) (io.ReadCloser, error)
- func (oss *OSS) Remove(ctx context.Context, info any) error
- func (oss *OSS) Stat(ctx context.Context, info any) error
- func (oss *OSS) StatFile(ctx context.Context, info any) (any, error)
- type Unknown
- func (u *Unknown) GetTags(ctx context.Context, info any) (map[string]string, error)
- func (*Unknown) ListObjects(ctx context.Context, source string, info any) (any, error)
- func (u *Unknown) ReadFile(ctx context.Context, info any) (io.ReadCloser, error)
- func (u *Unknown) Remove(ctx context.Context, info any) error
- func (u *Unknown) Stat(ctx context.Context, info any) error
- func (u *Unknown) StatFile(ctx context.Context, info any) (any, error)
Constants ¶
const ObjectNotExistMsg = "The specified key does not exist."
Variables ¶
var ( ErrUnknowDatasourceType = errors.New("unknown datasource type") ErrBucketNotProvided = errors.New("no bucket provided") ErrOSSNoSuchBucket = errors.New("no such bucket") ErrOSSNoSuchObject = errors.New("no such object in bucket") ErrOSSNoConfig = errors.New("no bucket or object config") )
Functions ¶
This section is empty.
Types ¶
type ChunkUploader ¶
type ChunkUploader interface { // Queries for blocks that have already been uploaded. CompletedChunks(context.Context, ...ChunkUploaderOption) (any, error) // CompletedChunks(context.Context, ...chunkUploaderOption) (any, error) // Generate uploadID for uploaded files NewMultipartIdentifier(context.Context, ...ChunkUploaderOption) (string, error) // Generate URLs for uploading files GenMultipartSignedURL(context.Context, ...ChunkUploaderOption) (string, error) // After all the chunks are uploaded, this interface is called and the backend merges the files. Complete(context.Context, ...ChunkUploaderOption) error // To stop the upload, the user needs to destroy the chunked data. Abort(context.Context, ...ChunkUploaderOption) error // IncompleteUpload returns the number of times an object does not have a complete upload. Ideally, // it is guaranteed that there is only one uploadid per object. // If there is more than one uploadid, return the latest one. IncompleteUpload(context.Context, ...ChunkUploaderOption) (string, error) }
Uploading files in chunks. 1. Get completed blocks 2. if there is no unique uploadid, you need to request a unique uploadid 3. request the upload file URL 4. Upload the file via the URL 5. Update the information of the uploaded block 6. merge files
type ChunkUploaderConf ¶
type ChunkUploaderConf struct {
// contains filtered or unexported fields
}
type ChunkUploaderOption ¶
type ChunkUploaderOption func(*ChunkUploaderConf)
func WithAnnotations ¶
func WithAnnotations(annotations map[string]string) ChunkUploaderOption
func WithBucket ¶
func WithBucket(bucket string) ChunkUploaderOption
func WithBucketPath ¶
func WithBucketPath(relativeDir string) ChunkUploaderOption
func WithFileName ¶
func WithFileName(fileName string) ChunkUploaderOption
func WithMD5 ¶
func WithMD5(md5 string) ChunkUploaderOption
func WithPartNumber ¶
func WithPartNumber(partNumber string) ChunkUploaderOption
func WithUploadID ¶
func WithUploadID(uploadID string) ChunkUploaderOption
type Datasource ¶
type Datasource interface { Stat(ctx context.Context, info any) error Remove(ctx context.Context, info any) error ReadFile(ctx context.Context, info any) (io.ReadCloser, error) StatFile(ctx context.Context, info any) (any, error) GetTags(ctx context.Context, info any) (map[string]string, error) ListObjects(ctx context.Context, source string, info any) (any, error) }
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a special datasource which use the system datasource as oss to store user-uploaded local files - `oss` in `Local` represents the system datasource oss client along with the `Local`'s oss info
func (*Local) ListObjects ¶
type OSS ¶
type OSS struct { *minio.Client *minio.Core }
OSS is a wrapper to object storage service
func (*OSS) Abort ¶
func (oss *OSS) Abort(ctx context.Context, options ...ChunkUploaderOption) error
func (*OSS) Complete ¶
func (oss *OSS) Complete(ctx context.Context, options ...ChunkUploaderOption) error