Example #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)
}
Example #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)
}
Example #3
0
func (fs Fs) Reader(f kit.File) (kit.ReadSeekerCloser, apperror.Error) {
	return fs.ReaderById(f.GetBucket(), f.GetBackendId())
}
Example #4
0
func (fs Fs) DeleteFile(f kit.File) apperror.Error {
	return fs.DeleteFileById(f.GetBucket(), f.GetBackendId())
}
Example #5
0
func (fs Fs) FileSize(file kit.File) (int64, apperror.Error) {
	return fs.FileSizeById(file.GetBucket(), file.GetBackendId())
}
Example #6
0
func (fs Fs) HasFile(f kit.File) (bool, apperror.Error) {
	return fs.HasFileById(f.GetBucket(), f.GetBackendId())
}