weed

package
v0.0.0-...-7a0ce36 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Inited = iota
	Uploading
	Manifest
	WeedDone
	DBDone
)
View Source
const (
	FilePath         = "/dir/assign"
	LookupVolumePath = "/dir/lookup"

	VolumeCacheKey = "weed:volumeid=%s"
)
View Source
const ChunkHashKey = "chunk:token=%s;offset=%d"

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(fid string) (err error)

func FetchFile

func FetchFile(fid string) (resp *http.Response, err error)

func GetDownloadUrl

func GetDownloadUrl(fid string) (*url.URL, error)

func InitHttpClient

func InitHttpClient(c *http.Client)

func IsSuccessStatus

func IsSuccessStatus(statuscode int) bool

func MasterUrl

func MasterUrl() (u *url.URL, err error)

func UploadSingleFile

func UploadSingleFile(f io.Reader, name string, fid string, volumeUrl string, isManifest bool) (resp *http.Response, err error)

Types

type ChunkInfo

type ChunkInfo struct {
	Fid    string `json:"fid"`
	Offset int64  `json:"offset"`
	Size   int64  `json:"size"`
}

type ChunkList

type ChunkList []*ChunkInfo

type ChunkManifest

type ChunkManifest struct {
	Name   string    `json:"name,omitempty"`
	Mime   string    `json:"mime,omitempty"`
	Size   int64     `json:"size,omitempty"`
	Chunks ChunkList `json:"chunks,omitempty"`
}

func (*ChunkManifest) Json

func (m *ChunkManifest) Json() ([]byte, error)

generate manifest reader

type Fid

type Fid struct {
	VolumeId   string
	FileId     string
	FileCookie string
}

func ParseFid

func ParseFid(fid string) (Fid, error)

type FileKeyInfo

type FileKeyInfo struct {
	Count     int    `json:"count"`
	Fid       string `json:"fid"`
	Url       string `json:"url"`
	PublicUrl string `json:"publicUrl"`
}

func AssignFileKey

func AssignFileKey() (*FileKeyInfo, error)

type FileUploadMeta

type FileUploadMeta struct {
	Token    string
	OwnerId  int64
	FolderId int64

	Status int // shouldn't modify directly

	Hash string
	Mime string
	Fid  string

	// chunk info
	ChunkManifest
	ChunkSize int64
}

func NewUploadMeta

func NewUploadMeta(ownerId int64, folderId int64, filename string, hash string, size int64, mime string) *FileUploadMeta

func (*FileUploadMeta) CheckChunkOffset

func (f *FileUploadMeta) CheckChunkOffset(offset int64, size int64) (uploaded bool, err error)

func (*FileUploadMeta) CheckFileHash

func (f *FileUploadMeta) CheckFileHash() error

func (*FileUploadMeta) GetChunkHashFromCache

func (f *FileUploadMeta) GetChunkHashFromCache(chunk *ChunkInfo) (string, error)

func (*FileUploadMeta) Marshal

func (f *FileUploadMeta) Marshal() ([]byte, error)

func (*FileUploadMeta) SetStatus

func (f *FileUploadMeta) SetStatus(s int)

func (*FileUploadMeta) StoreChunkHash

func (f *FileUploadMeta) StoreChunkHash(chunk *ChunkInfo, hash string) error

func (*FileUploadMeta) Unmarshal

func (f *FileUploadMeta) Unmarshal(b []byte) error

func (*FileUploadMeta) Upload

func (f *FileUploadMeta) Upload(raw []byte, offset int64, hash string) error

always upload in chunk, just make it simple

func (*FileUploadMeta) UploadManifest

func (f *FileUploadMeta) UploadManifest() error

func (*FileUploadMeta) UploadedChunks

func (f *FileUploadMeta) UploadedChunks() []int64

type VolumeLookupInfo

type VolumeLookupInfo struct {
	VolumeId  string `json:"volumeId"`
	Locations []struct {
		PublicUrl string `json:"publicUrl"`
		Url       string `json:"url"`
	} `json:"locations"`
}

func LookupVolume

func LookupVolume(volumeId string) (*VolumeLookupInfo, error)

func LookupVolumeNoCache

func LookupVolumeNoCache(volumeId string) (*VolumeLookupInfo, error)

func (*VolumeLookupInfo) Marshal

func (v *VolumeLookupInfo) Marshal() ([]byte, error)

func (*VolumeLookupInfo) Unmarshal

func (v *VolumeLookupInfo) Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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