textiot
Version:
A framework for building web and native (IoT) Dapps on the IPFS network
53 lines (52 loc) • 1.81 kB
TypeScript
import { API } from '../core/api';
import { ApiOptions, FilesList, Files as FilesType, Keys, Block } from '../models';
import Mills from './mills';
import Threads from './threads';
/**
* Files is an API module for managing Textile files
*
* @extends {API}
*/
export default class Files extends API {
mills: Mills;
threads: Threads;
constructor(opts?: ApiOptions);
/**
* Get a paginated array of files.
*
* @param thread Thread ID (can also use ‘default’). Omit for all
* @param offset Offset ID to start listing from. Omit for latest
* @param limit List page size (default 5)
* @returns An array of Thread objects
*/
list(thread?: string, offset?: string, limit?: number): Promise<FilesList>;
/**
* Retrieves file encryption/decryption keys under the given target
*
* Note that the target id is _not_ the same as the block id. The target is the actual target
* file object.
*
* @param target ID of the target file
* @returns An array of file keys
*/
keys(target: string): Promise<Keys>;
/**
* Ignores a thread file by its block ID
*
* This adds an 'ignore' thread block targeted at the file.
* Ignored blocks are by default not returned when listing.
*
* @param id ID of the thread file
* @returns The added ignore block
*/
ignore(id: string): Promise<Block>;
/**
* Add a file to a thread in your Textile node
*
* @param thread Id of the thread
* @param file A FormData object or a function for creating a FormData object
* @param caption Caption to associated with the added file object
* @returns An array of created File objects
*/
add(file: any, caption: string, thread?: string): Promise<FilesType>;
}