added copying and moving
This commit is contained in:
@@ -46,6 +46,35 @@ func (s *StorageService) DownloadFilePrep(abs_path string) (*os.File, string, in
|
||||
return f, filepath.Base(abs_path), info.Size(), nil
|
||||
}
|
||||
|
||||
func (s *StorageService) Move(src_abs_path string, dest_abs_path string) error {
|
||||
_, err := s.storageRepo.EntryInfo(src_abs_path)
|
||||
if err != nil {
|
||||
return responseErrors.ErrFileDoesNotExist
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
return responseErrors.ErrNameTaken
|
||||
} else if os.IsNotExist(err) {
|
||||
return s.storageRepo.Move(src_abs_path, dest_abs_path)
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
func (s *StorageService) Copy(src_abs_path string, dest_abs_path string) error {
|
||||
_, err := s.storageRepo.EntryInfo(src_abs_path)
|
||||
if err != nil {
|
||||
return responseErrors.ErrFileDoesNotExist
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
return responseErrors.ErrNameTaken
|
||||
} else if os.IsNotExist(err) {
|
||||
return s.storageRepo.Copy(src_abs_path, dest_abs_path)
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StorageService) UploadFile(c fiber.Ctx, abs_path string, f *multipart.FileHeader) error {
|
||||
info, err := s.storageRepo.EntryInfo(abs_path)
|
||||
if err != nil || !info.IsDir() {
|
||||
|
||||
Reference in New Issue
Block a user