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

Change the return type of downloadBlocks to []byte in wasm #1218

Merged
merged 2 commits into from
Sep 11, 2023
Merged
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
11 changes: 1 addition & 10 deletions wasmsdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,7 @@ download blocks of a file

**Output**:

> {commandSuccess:bool, fileName:string,url:string, error:string}

**Example**

```json
{
"commandSuccess": true,
"fileName": "scan3.png",
"url": "blob:http://localhost:3000/42157751-1d33-4448-88c8-7d7e2ad887a5"
}
> {[]byte, error:string}
```

### zcn.sdk.upload
Expand Down
12 changes: 2 additions & 10 deletions wasmsdk/blobber.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ func upload(allocationID, remotePath string, fileBytes, thumbnailBytes []byte, w
}

// download download file blocks
func downloadBlocks(allocationID, remotePath, authTicket, lookupHash string, numBlocks int, startBlockNumber, endBlockNumber int64, callbackFuncName string, isFinal bool) (*DownloadCommandResponse, error) {
func downloadBlocks(allocationID, remotePath, authTicket, lookupHash string, numBlocks int, startBlockNumber, endBlockNumber int64, callbackFuncName string, isFinal bool) ([]byte, error) {

if len(remotePath) == 0 && len(authTicket) == 0 {
return nil, RequiredArg("remotePath/authTicket")
Expand Down Expand Up @@ -920,15 +920,7 @@ func downloadBlocks(allocationID, remotePath, authTicket, lookupHash string, num
return nil, errors.New("Download failed: unknown error")
}

resp := &DownloadCommandResponse{
CommandSuccess: true,
FileName: fileName,
}

resp.Url = CreateObjectURL(mf.Buffer.Bytes(), "application/octet-stream")

return resp, nil

return mf.Buffer.Bytes(), nil
}

// GetBlobbersList get list of active blobbers, and format them as array json string
Expand Down
Loading