Skip to content

Instantly share code, notes, and snippets.

@sunho
Created January 10, 2021 15:09
Show Gist options
  • Save sunho/05af9f0d57fdbde0bf499b3c8c67d2a9 to your computer and use it in GitHub Desktop.
Save sunho/05af9f0d57fdbde0bf499b3c8c67d2a9 to your computer and use it in GitHub Desktop.
type PicServiceConfig struct {
BucketName string `yaml:"bucket_name"`
}
type PicService struct {
S3Service *S3Service `dim:"on"` // 여기로 서비스 인스턴스가 주입됩니다.
bucket string
}
func (p *PicService) Init(conf dim.ServiceConfig) error {
conf2 := conf.(*PicServiceConfig)
p.bucket = conf2.BucketName
return nil
}
func (PicService) DefaultConfig() dim.ServiceConfig {
return &PicServiceConfig {
BucketName: "picture",
}
}
func (PicService) ConfigName() string {
return "picservice"
}
func (p *PicService) SavePic(buf []byte) {
p.S3Service.Store(p.bucket, buf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment