Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

[DRAFT] File data representation. #13

Merged
merged 2 commits into from
Nov 26, 2018
Merged
Changes from 1 commit
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
22 changes: 21 additions & 1 deletion SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,31 @@ The `type` field is either `file` or `dir`.
A file object has the following fields.

- `type`: String with value of `'file'`.
- `data`: TODO: Define structure for file content data.
- `data`: Array of `file-data`.
- `size`: Integer. Cumulative size of `data`.

The `type` field must be set to `file`.

### `file-data`

File data is an Array. Each element is an Array with only 2 elements (Tuple).

- 0: Array. Tuple containing two integers, the `start` and `end` offsets of the content.
- 0: Integer: start offset.
- 1: Integer: end offset.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative that would be less error prone for implementations would be to give the size of each chunk rather than the end of the offset.

- 1: Link. Either a `raw` link or a link to another node formatted as `file-data`.

```javascript
[
[ [0, 1024], Link ],
[ [1025, 1089], Link ]
]
```

Implementations are encouraged to use nested `file-data` array nodes through links for files
with many chunks in order to limit the size of the serialized node. No strict boundary is
set but it is typical to try and limit node size to less than one megabyte.

## IPLD `dir`

A directory object represents a directory.
Expand Down