Skip to content

Commit

Permalink
feat: cloudinary upload helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaanqui committed Apr 28, 2024
1 parent 683ea0f commit 73a942e
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions services/image_upload_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ import (
"context"

"github.com/99designs/gqlgen/graphql"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudinary/cloudinary-go/v2/api/uploader"
)

func (service Service) CloudflareImageUpload(ctx context.Context, data cloudflare.UploadImageParams) (cloudflare.Image, error) {
cf_resource_container := cloudflare.ResourceContainer{
Level: cloudflare.UserRouteLevel,
Type: cloudflare.UserType,
Identifier: "<PASTE_IDENTIFIER_HERE>",
}
return service.CloudflareApi.UploadImage(ctx, &cf_resource_container, data)
}

func (service Service) GraphImageUpload(ctx context.Context, file graphql.Upload) (cloudflare.Image, error) {
return service.CloudflareImageUpload(ctx, cloudflare.UploadImageParams{
File: nil,
})
func (service Service) GraphImageUpload(
ctx context.Context,
file graphql.Upload,
params uploader.UploadParams,
) (*uploader.UploadResult, error) {
return service.Cloudinary.Upload.Upload(ctx, file.File, params)
}

0 comments on commit 73a942e

Please sign in to comment.