Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tarassh committed Aug 22, 2024
1 parent ac0fd7d commit 7908393
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/storage/ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,19 @@ func (store *ipfsStore) createMultiformWriter(contents []byte) (*bytes.Buffer, s
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)

if err := writer.WriteField("filedata", string(contents)); err != nil {
return body, "", fmt.Errorf("error writing form field: %w", err)
// Create a new form-data header with the filename and write the file content
part, err := writer.CreateFormFile("file", "specimen")
if err != nil {
return nil, "", fmt.Errorf("error creating form file: %w", err)
}

Check warning on line 111 in internal/storage/ipfs.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/ipfs.go#L107-L111

Added lines #L107 - L111 were not covered by tests

if _, err := part.Write(contents); err != nil {
return nil, "", fmt.Errorf("error writing file content: %w", err)

Check warning on line 114 in internal/storage/ipfs.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/ipfs.go#L113-L114

Added lines #L113 - L114 were not covered by tests
}

// Close the multipart writer
if err := writer.Close(); err != nil {
log.Error("error closing multipart writer", err)
return nil, "", fmt.Errorf("error closing multipart writer: %w", err)

Check warning on line 119 in internal/storage/ipfs.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/ipfs.go#L119

Added line #L119 was not covered by tests
}

return body, writer.FormDataContentType(), nil
Expand Down

0 comments on commit 7908393

Please sign in to comment.