예제 #1
0
func (this *Swiftio) PutStream(filename string, info FileMeta) (io.WriteCloser, error) {
	if info == nil || !CheckIntegrity(info) {
		return nil, exception.EX_METADATA_NEEDS_TO_BE_SPECIFIED
	}
	meta := swift.Metadata(info)

	fileW, err := this.conn.c.ObjectCreate(this.container, filename, false, "", "", meta.ObjectHeaders())
	if err != nil {
		return nil, err
	}
	return fileW, nil
}
예제 #2
0
func (this *Swiftio) Put(filename string, content filetype.Filetype, info FileMeta) error {
	if info == nil {
		info = FileMeta(map[string]string{})
	}
	meta := swift.Metadata(info.Clone())
	meta[METAKEY_TYPE] = content.GetType()

	buffer := &bytes.Buffer{}
	content.WriteBack(buffer)

	_, err := this.conn.c.ObjectPut(this.container, filename, buffer, false, "", "", meta.ObjectHeaders())
	return err
}
예제 #3
0
func (this *Swiftio) Copy(srcname string, desname string, overrideMeta FileMeta) error {
	var _, err = this.conn.c.ObjectCopy(this.container, srcname, this.container, desname, swift.Metadata(overrideMeta).ObjectHeaders())
	return err
}
예제 #4
0
func (this *Swiftio) Putinfo(filename string, info FileMeta) error {
	head4Put := swift.Metadata(info).ObjectHeaders()
	return this.conn.c.ObjectUpdate(this.container, filename, head4Put)
}