fix: if we get an ErrUnexpectedEOF due to being less than512 bytes, read it all instead

This commit is contained in:
Derrick Hammer 2024-03-02 04:45:09 -05:00
parent 8a112a8c12
commit a9c2ecade0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 1 deletions

View File

@ -174,6 +174,7 @@ func (s StorageServiceDefault) UploadObject(ctx context.Context, protocol Storag
} }
_, err = io.ReadFull(reader, mimeBytes) _, err = io.ReadFull(reader, mimeBytes)
if err != nil { if err != nil {
if !errors.Is(err, io.ErrUnexpectedEOF) {
return nil, err return nil, err
} }
@ -182,6 +183,14 @@ func (s StorageServiceDefault) UploadObject(ctx context.Context, protocol Storag
return nil, err return nil, err
} }
mimeBytes, err = io.ReadAll(reader)
}
reader, err = getReader()
if err != nil {
return nil, err
}
mimeType := http.DetectContentType(mimeBytes) mimeType := http.DetectContentType(mimeBytes)
protocolName := protocol.Name() protocolName := protocol.Name()