Skip to content

Commit

Permalink
fix: cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jul 16, 2024
1 parent 89e30a3 commit f803a68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 5 additions & 5 deletions internal/object/object.repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Repository interface {
Upload(file []byte, bucketName string, objectKey string) (url string, key string, err error)
Delete(bucketName string, objectKey string) (err error)
Get(bucketName string, objectKey string) (url string, err error)
GetURL(bucketName string, objectKey string) string
GetURL(objectKey string) string
}

type repositoryImpl struct {
Expand Down Expand Up @@ -46,7 +46,7 @@ func (r *repositoryImpl) Upload(file []byte, bucketName string, objectKey string
return "", "", errors.Wrap(err, fmt.Sprintf("Couldn't upload object to %v/%v.", bucketName, objectKey))
}

return r.GetURL(bucketName, objectKey), objectKey, nil
return r.GetURL(objectKey), objectKey, nil
}

func (r *repositoryImpl) Delete(bucketName string, objectKey string) (err error) {
Expand All @@ -67,7 +67,7 @@ func (r *repositoryImpl) Get(bucketName string, objectKey string) (url string, e
_, cancel := context.WithTimeout(ctx, 50*time.Second)
defer cancel()

url = r.GetURL(bucketName, objectKey)
url = r.GetURL(objectKey)

resp, err := r.httpClient.Get(url)
if err != nil {
Expand All @@ -80,6 +80,6 @@ func (r *repositoryImpl) Get(bucketName string, objectKey string) (url string, e
return url, nil
}

func (r *repositoryImpl) GetURL(bucketName string, objectKey string) string {
return r.conf.CDNEndpoint + "/" + bucketName + "/" + objectKey
func (r *repositoryImpl) GetURL(objectKey string) string {
return r.conf.CDNEndpoint + "/" + objectKey
}
4 changes: 0 additions & 4 deletions internal/object/object.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,3 @@ func (s *serviceImpl) DeleteByKey(_ context.Context, req *proto.DeleteByKeyObjec
Success: true,
}, nil
}

func (s *serviceImpl) GetURL(bucketName string, objectKey string) string {
return "https://" + s.conf.Endpoint + "/" + bucketName + "/" + objectKey
}

0 comments on commit f803a68

Please sign in to comment.