You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
530 B
Go
31 lines
530 B
Go
3 years ago
|
package domain
|
||
|
|
||
|
import "io"
|
||
|
|
||
|
type BogFileService struct {
|
||
|
user_agent_repo UserAgentRepository
|
||
|
file_data_repo FileDataRepository
|
||
|
}
|
||
|
|
||
|
func (b *BogFileService) RecieveFile(src FileSource) error {
|
||
|
f, err := b.file_data_repo.OpenOrCreate(src.Path(), src.UserAgent())
|
||
|
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
io.Copy(f, src)
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (b *BogFileService) SendFile(dst FileDestination) error {
|
||
|
f, err := b.file_data_repo.OpenOrCreate(dst.Path(), dst.UserAgent())
|
||
|
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
io.Copy(dst, f)
|
||
|
return nil
|
||
|
}
|