Export S3 client of Server

This commit is contained in:
Lena Fuhrimann 2017-03-12 16:07:59 +01:00
parent c96a874900
commit dadd54eb01
3 changed files with 10 additions and 10 deletions

12
api.go
View file

@ -29,7 +29,7 @@ func (s *Server) CreateBucketHandler() http.Handler {
return
}
err = s.s3.MakeBucket(bucket.Name, "")
err = s.S3.MakeBucket(bucket.Name, "")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
@ -64,7 +64,7 @@ func (s *Server) CreateObjectHandler() http.Handler {
objectSource := fmt.Sprintf("/%s/%s", copy.SourceBucketName, copy.SourceObjectName)
fmt.Println(copy)
fmt.Println(objectSource)
err = s.s3.CopyObject(copy.BucketName, copy.ObjectName, objectSource, copyConds)
err = s.S3.CopyObject(copy.BucketName, copy.ObjectName, objectSource, copyConds)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
@ -90,7 +90,7 @@ func (s *Server) CreateObjectHandler() http.Handler {
}
defer file.Close()
_, err = s.s3.PutObject(vars["bucketName"], handler.Filename, file, "application/octet-stream")
_, err = s.S3.PutObject(vars["bucketName"], handler.Filename, file, "application/octet-stream")
if err != nil {
w.WriteHeader(http.StatusUnprocessableEntity)
return
@ -106,7 +106,7 @@ func (s *Server) DeleteBucketHandler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
err := s.s3.RemoveBucket(vars["bucketName"])
err := s.S3.RemoveBucket(vars["bucketName"])
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
@ -121,7 +121,7 @@ func (s *Server) DeleteObjectHandler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
err := s.s3.RemoveObject(vars["bucketName"], vars["objectName"])
err := s.S3.RemoveObject(vars["bucketName"], vars["objectName"])
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
@ -137,7 +137,7 @@ func (s *Server) GetObjectHandler() http.Handler {
vars := mux.Vars(r)
objectName := vars["objectName"]
object, err := s.s3.GetObject(vars["bucketName"], objectName)
object, err := s.S3.GetObject(vars["bucketName"], objectName)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return

View file

@ -11,7 +11,7 @@ import (
// Server is a server containing a minio client
type Server struct {
s3 *minio.Client
S3 *minio.Client
}
func main() {
@ -21,7 +21,7 @@ func main() {
}
s := &Server{
s3: NewMinioClient(),
S3: NewMinioClient(),
}
router := mux.NewRouter()

View file

@ -38,7 +38,7 @@ func (s *Server) BucketPageHandler() http.Handler {
doneCh := make(chan struct{})
objectCh := s.s3.ListObjectsV2(bucketName, "", false, doneCh)
objectCh := s.S3.ListObjectsV2(bucketName, "", false, doneCh)
for object := range objectCh {
if object.Err != nil {
w.WriteHeader(http.StatusInternalServerError)
@ -73,7 +73,7 @@ func (s *Server) BucketsPageHandler() http.Handler {
return
}
buckets, err := s.s3.ListBuckets()
buckets, err := s.S3.ListBuckets()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return