Пример #1
0
func (f *Fdfs) getClient() fdfs.FdfsClient {
	if client == nil {
		lock <- 0
		if !initialized {
			if client == nil {
				var e error
				client, e = fdfs.NewFdfsClient([]string{f.TrackerDomain}, strconv.Itoa(f.Port))
				if e != nil {
					return nil, e
				}
			}
			initialized = true
		}
		<-lock
	}
	return client, nil
}
Пример #2
0
func (this *Fdfs) GetImage() ([]byte, error) {
	if client == nil {
		lock <- 0
		if !initialized {
			if client == nil {
				var e error
				client, e = fdfs.NewFdfsClient([]string{this.TrackerDomain}, strconv.Itoa(this.Port))
				if e != nil {
					return nil, e
				}
			}
			initialized = true
		}
		<-lock
	}
	bts, err := client.DownloadToBuffer(this.Path, this.Cat)
	if err != nil {
		return nil, err
	} else {
		return bts, nil
	}
}