View Source MyspaceIPFS.Files (Myspace IPFS v0.2.0-alpha.2)

MyspaceIPFS.Files is where the files commands of the IPFS API reside.

Link to this section Summary

Types

List of entries in a directory. Each entry is a FileEntry hash.

A FileEntry struct.

A FileStat struct.

Functions

Change the CID version or hash function of a path's root node.

Copy files into mfs.

Flush a given path's data to disk.

List directories in the local mutable namespace. https://docs.ipfs.io/reference/http/api/#api-v0-files-ls

List directories in the local mutable namespace.

Make directories.

Move files.

Read a file in a given mfs.

Remove a file from mfs.

Get file status.

Write to a mutable file in a given filesystem.

Link to this section Types

@type entries() :: %MyspaceIPFS.FilesEntries{entries: [entry()]}

List of entries in a directory. Each entry is a FileEntry hash.

@type entry() :: %MyspaceIPFS.FilesEntry{
  hash: binary(),
  name: binary(),
  size: non_neg_integer(),
  type: binary()
}

A FileEntry struct.

@type stat() :: %MyspaceIPFS.FilesStat{
  blocks: non_neg_integer(),
  cumulative_size: non_neg_integer(),
  hash: MyspaceIPFS.hash(),
  size: non_neg_integer(),
  type: binary()
}

A FileStat struct.

Link to this section Functions

@spec chcid(Path.t(), list()) :: {:ok, any()} | MyspaceIPFS.Api.error_response()

Change the CID version or hash function of a path's root node.

parameters

Parameters

path: The path to change the CID for,dest if in doubt use "/"

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-chcid

[
  cid-version: <int>, # CID version. (experimental)
  hash: <string>, # Hash function to use. Implies CID version 1 if used. (experimental)
]
Link to this function

cp(source, dest, opts \\ [])

View Source
@spec cp(Path.t(), Path.t(), list()) :: :ok | MyspaceIPFS.Api.error_response()

Copy files into mfs.

parameters

Parameters

source: The source file to copy. dest: The destination path for the file to be copied to.

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-cp

[
  parents: <bool>, # Make parent directories as needed.
]
@spec flush() :: {:ok, any()} | MyspaceIPFS.Api.error_response()

Flush a given path's data to disk.

parameters

Parameters

https://docs.ipfs.io/reference/http/api/#api-v0-files-flush path - The path to flush. If not specified, the entire repo will be flushed.

@spec flush(Path.t()) :: {:ok, any()} | MyspaceIPFS.Api.error_response()
@spec ls(Path.t(), list()) :: {:ok, list()} | MyspaceIPFS.Api.error_response()

List directories in the local mutable namespace. https://docs.ipfs.io/reference/http/api/#api-v0-files-ls

This command only returns the filepaths of the files in the directory.

parameters

Parameters

path| - The path to list. If in doubt, use "/".

options

Options

[
  l: <bool>, # Use long listing format.
  U: <bool>, # Do not sort; list entries in directory order.
]
@spec ls!(Path.t(), list()) ::
  entries() | [binary()] | MyspaceIPFS.Api.error_response()

List directories in the local mutable namespace.

parameters

Parameters

path| - The path to list. If in doubt, use "/".

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-ls

[
  l: <bool>, # Use long listing format.
  U: <bool>, # Do not sort; list entries in directory order.
]
@spec mkdir(Path.t(), list()) :: :ok | MyspaceIPFS.Api.error_response()

Make directories.

parameters

Parameters

path - The path to make directories at.

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-mkdir

[
  `parents` - <bool>, # No error if existing, make parent directories as needed.
  `hash` - <string>, # Hash function to use. Implies CID version 1 if used. (experimental)
  `cid-version` - <int>, # CID version. (experimental)
]
@spec mv(Path.t(), Path.t()) :: :ok | MyspaceIPFS.Api.error_response()

Move files.

parameters

Parameters

source - The source file to move. dest - The destination path for the file to be moved to.

@spec read(Path.t(), list()) :: {:ok, any()} | MyspaceIPFS.Api.error_response()
@spec read!(Path.t(), list()) :: any() | MyspaceIPFS.Api.error_response()

Read a file in a given mfs.

parameters

Parameters

path - The path to the file to be read.

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-read

[
  offset: <int>, # Byte offset to begin reading from.
  count: <int>, # Maximum number of bytes to read.
]
@spec rm(Path.t(), list()) :: :ok | {:error, binary()}

Remove a file from mfs.

parameters

Parameters

path - The path to the file to be removed.

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-rm

[
  r|recursive: <bool>, # Recursively remove directories.
  force: <bool>, # Forcibly remove target at path; implies recursive for directories.
]
@spec stat(Path.t(), list()) :: {:ok, any()} | MyspaceIPFS.Api.error_response()

Get file status.

parameters

Parameters

path - The path to the file to stat.

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-stat

[
  format: <string>, # Format to print out.
                    Allowed tokens:
                    <hash> <size> <cumulsize> <type> <childs>
  hash: <bool>, # Compute the hash of the file.
  size: <bool>, # Compute the size of the file.
  with-local: <bool>, # Compute the size of the file including the local repo.
]
Link to this function

write(data, path, opts \\ [])

View Source
@spec write(binary(), Path.t(), list()) :: :ok | MyspaceIPFS.Api.error_response()

Write to a mutable file in a given filesystem.

parameters

Parameters

path - The path to write to. data - The data to write.

options

Options

https://docs.ipfs.io/reference/http/api/#api-v0-files-write

[
  create: <bool>, # Create the file if it does not exist.
  truncate: <bool>, # Truncate the file to size zero before writing.
  offset: <int>, # Byte offset to begin writing at.
  count: <int>, # Maximum number of bytes to write.
  raw-leaves: <bool>, # Use raw blocks for newly created leaf nodes. (experimental)
  cid-version: <int>, # CID version. (experimental)
  hash: <string>, # Hash function to use. Implies CID version 1 if used. (experimental)
  parents: <bool>, # No error if existing, make parent directories as needed.
]