-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: downloading blocks of a file by index (#271)
* feat: implemented uploading data by block index * feat: tests and docs for uploading by block index * feat: downloading data by index * fix: added options * docs: added example * test: include more info about fairos error * test: include more info about fairos error * test: added configurable fairos image to prevent errors from non-stable version * test: added configurable fairos image to prevent errors from non-stable version
- Loading branch information
1 parent
37f7207
commit c734585
Showing
9 changed files
with
163 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createFdp, generateRandomHexString, generateUser, makeFileContent } from '../../utils' | ||
import { wrapBytesWithHelpers } from '../../../src/utils/bytes' | ||
|
||
jest.setTimeout(400000) | ||
it('Download by index', async () => { | ||
const fdp = createFdp() | ||
const pod = generateRandomHexString() | ||
const { size, blocksCount, blockSize, content, filename, fullPath } = makeFileContent(5000005) | ||
generateUser(fdp) | ||
await fdp.personalStorage.create(pod) | ||
await fdp.file.uploadData(pod, fullPath, content) | ||
const fileMeta = await fdp.file.getMetadata(pod, fullPath) | ||
expect(fileMeta.fileName).toEqual(filename) | ||
expect(fileMeta.blockSize).toEqual(blockSize) | ||
expect(fileMeta.fileSize).toEqual(size) | ||
|
||
const result = new Uint8Array(fileMeta.fileSize) | ||
for (let i = 0; i < blocksCount; i++) { | ||
result.set(await fdp.file.downloadDataBlock(fileMeta, i), i * blockSize) | ||
} | ||
|
||
const dataBig = wrapBytesWithHelpers(await fdp.file.downloadData(pod, fullPath)).text() | ||
expect(dataBig).toEqual(content) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters