Fix cannot upload organiation logo
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -46,10 +46,7 @@ type (
|
|||||||
UpdateOrganizationRequest struct {
|
UpdateOrganizationRequest struct {
|
||||||
ID gid.GID
|
ID gid.GID
|
||||||
Name *string
|
Name *string
|
||||||
File io.Reader
|
File *File
|
||||||
Filename string
|
|
||||||
FileSize int64
|
|
||||||
ContentType string
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -138,11 +135,11 @@ func (s OrganizationService) Update(
|
|||||||
|
|
||||||
var fileSize int64
|
var fileSize int64
|
||||||
var fileContent io.ReadSeeker
|
var fileContent io.ReadSeeker
|
||||||
filename := req.Filename
|
filename := req.File.Filename
|
||||||
contentType := req.ContentType
|
contentType := req.File.ContentType
|
||||||
|
|
||||||
if seeker, ok := req.File.(io.Seeker); ok {
|
if seeker, ok := req.File.Content.(io.Seeker); ok {
|
||||||
if req.FileSize <= 0 {
|
if req.File.Size <= 0 {
|
||||||
size, err := seeker.Seek(0, io.SeekEnd)
|
size, err := seeker.Seek(0, io.SeekEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot determine file size: %w", err)
|
return fmt.Errorf("cannot determine file size: %w", err)
|
||||||
@@ -154,11 +151,11 @@ func (s OrganizationService) Update(
|
|||||||
return fmt.Errorf("cannot reset file position: %w", err)
|
return fmt.Errorf("cannot reset file position: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileSize = req.FileSize
|
fileSize = req.File.Size
|
||||||
}
|
}
|
||||||
fileContent = req.File.(io.ReadSeeker)
|
fileContent = req.File.Content.(io.ReadSeeker)
|
||||||
} else {
|
} else {
|
||||||
buf, err := io.ReadAll(req.File)
|
buf, err := io.ReadAll(req.File.Content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot read file: %w", err)
|
return fmt.Errorf("cannot read file: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,7 +334,12 @@ func (r *mutationResolver) UpdateOrganization(ctx context.Context, input types.U
|
|||||||
}
|
}
|
||||||
|
|
||||||
if input.Logo != nil {
|
if input.Logo != nil {
|
||||||
req.File = input.Logo.File
|
req.File = &probo.File{
|
||||||
|
Filename: input.Logo.Filename,
|
||||||
|
ContentType: input.Logo.ContentType,
|
||||||
|
Size: input.Logo.Size,
|
||||||
|
Content: input.Logo.File,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
organization, err := svc.Organizations.Update(ctx, req)
|
organization, err := svc.Organizations.Update(ctx, req)
|
||||||
|
|||||||
Reference in New Issue
Block a user