Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSP agent -> Pinner multipart upload fix #280

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
reviewers:
- "noslav"
- "rogarcia"
4 changes: 4 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
bsp-agent-eth:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ !env.ACT }}
uses: docker/login-action@v1
Expand Down
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 @@
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
Loading