Beispiel #1
0
func (fs Fs) Writer(f kit.File, create bool) (string, io.WriteCloser, apperror.Error) {
	id := f.GetBackendId()
	if create {
		id = f.GetFullName()
	}
	return fs.WriterById(f.GetBucket(), id, create)
}
Beispiel #2
0
func (h *FileService) Delete(f kit.File, u kit.User) apperror.Error {
	// Delete file from backend.
	if f.GetBackendName() != "" && f.GetBackendId() != "" {
		backend := h.Backend(f.GetBackendName())
		if backend == nil {
			h.Registry().Logger().Errorf("Deleting file %v in backend %v, which is unconfigured", f.GetId(), f.GetBackendName())
		} else {
			if err := backend.DeleteFile(f); err != nil {
				return err
			}
		}
	}

	return h.resource.Delete(f, u)
}
Beispiel #3
0
func (fs Fs) Reader(f kit.File) (kit.ReadSeekerCloser, apperror.Error) {
	return fs.ReaderById(f.GetBucket(), f.GetBackendId())
}
Beispiel #4
0
func (fs Fs) DeleteFile(f kit.File) apperror.Error {
	return fs.DeleteFileById(f.GetBucket(), f.GetBackendId())
}
Beispiel #5
0
func (fs Fs) FileSize(file kit.File) (int64, apperror.Error) {
	return fs.FileSizeById(file.GetBucket(), file.GetBackendId())
}
Beispiel #6
0
func (fs Fs) HasFile(f kit.File) (bool, apperror.Error) {
	return fs.HasFileById(f.GetBucket(), f.GetBackendId())
}