diff --git a/src/FS/copy.md b/src/FS/copy.md index 69ab7cc..e9792fa 100755 --- a/src/FS/copy.md +++ b/src/FS/copy.md @@ -11,6 +11,7 @@ Copies a file or directory from one location to another. ```js puter.fs.copy(source, destination) puter.fs.copy(source, destination, options) +puter.fs.copy(options) ``` ## Parameters @@ -27,6 +28,8 @@ The path to the destination directory. If destination is a directory then the fi The options for the `copy` operation. The following options are supported: +- `source` (String) - Path to the file or directory to copy. Required when passing options as the only argument. +- `destination` (String) - Path to the destination. Required when passing options as the only argument. - `overwrite` (Boolean) - Whether to overwrite the destination file or directory if it already exists. Defaults to `false`. - `dedupeName` (Boolean) - Whether to deduplicate the file or directory name if it already exists. Defaults to `false`. - `newName` (String) - The new name to use for the copied file or directory. Defaults to `undefined`. diff --git a/src/FS/delete.md b/src/FS/delete.md index badfed9..111e49c 100755 --- a/src/FS/delete.md +++ b/src/FS/delete.md @@ -9,21 +9,23 @@ Deletes a file or directory. ## Syntax ```js -puter.fs.delete(path) -puter.fs.delete(path, options) +puter.fs.delete(paths) +puter.fs.delete(paths, options) +puter.fs.delete(options) ``` ## Parameters -#### `path` (String) (required) +#### `paths` (String | String[]) (required) -Path of the file or directory to delete. -If `path` is not absolute, it will be resolved relative to the app's root directory. +A single path or array of paths of the file(s) or directory(ies) to delete. +If a path is not absolute, it will be resolved relative to the app's root directory. #### `options` (Object) (optional) The options for the `delete` operation. The following options are supported: +- `paths` (String | String[]) - A single path or array of paths to delete. Required when passing options as the only argument. - `recursive` (Boolean) - Whether to delete the directory recursively. Defaults to `true`. - `descendantsOnly` (Boolean) - Whether to delete only the descendants of the directory and not the directory itself. Defaults to `false`. diff --git a/src/FS/getReadURL.md b/src/FS/getReadURL.md index 62ecca5..6bd8240 100644 --- a/src/FS/getReadURL.md +++ b/src/FS/getReadURL.md @@ -23,7 +23,7 @@ The path to the file to read. The number of seconds until the URL expires. If not provided, the URL will expire in 24 hours. -## Returns +## Return value A promise that resolves to a URL string that can be used to read the file. diff --git a/src/FS/mkdir.md b/src/FS/mkdir.md index 8c8c8c1..827a351 100755 --- a/src/FS/mkdir.md +++ b/src/FS/mkdir.md @@ -7,23 +7,31 @@ platforms: [websites, apps, nodejs, workers] Allows you to create a directory. ## Syntax + ```js puter.fs.mkdir(path) puter.fs.mkdir(path, options) +puter.fs.mkdir(options) ``` ## Parameters -#### `path` (string) (required) + +#### `path` (String) (required) + The path to the directory to create. If path is not absolute, it will be resolved relative to the app's root directory. -#### `options` (object) +#### `options` (Object) + The options for the `mkdir` operation. The following options are supported: -- `overwrite` (boolean) - Whether to overwrite the directory if it already exists. Defaults to `false`. -- `dedupeName` (boolean) - Whether to deduplicate the directory name if it already exists. Defaults to `false`. -- `createMissingParents` (boolean) - Whether to create missing parent directories. Defaults to `false`. + +- `path` (String) The directory path to be created if not specified via function parameter. +- `overwrite` (Boolean) - Whether to overwrite the directory if it already exists. Defaults to `false`. +- `dedupeName` (Boolean) - Whether to deduplicate the directory name if it already exists. Defaults to `false`. +- `createMissingParents` (Boolean) - Whether to create missing parent directories. Defaults to `false`. ## Return value + Returns a `Promise` that resolves to the [`FSItem`](/Objects/fsitem) object of the created directory. ## Examples diff --git a/src/FS/move.md b/src/FS/move.md index 705d945..251db0c 100755 --- a/src/FS/move.md +++ b/src/FS/move.md @@ -11,22 +11,31 @@ Moves a file or a directory from one location to another. ```js puter.fs.move(source, destination) puter.fs.move(source, destination, options) +puter.fs.move(options) ``` ## Parameters + #### `source` (String) (Required) + The path to the file or directory to move. #### `destination` (String) (Required) + The path to the destination directory. If destination is a directory then the file or directory will be moved into that directory using the same name as the source file or directory. If the destination is a file, we overwrite if overwrite is `true`, otherwise we error. #### `options` (Object) (Optional) + The options for the `move` operation. The following options are supported: + +- `source` (String) - Path to the file or directory to move. Required when passing options as the only argument. +- `destination` (String) - Path to the destination. Required when passing options as the only argument. - `overwrite` (Boolean) - Whether to overwrite the destination file or directory if it already exists. Defaults to `false`. - `dedupeName` (Boolean) - Whether to deduplicate the file or directory name if it already exists. Defaults to `false`. - `createMissingParents` (Boolean) - Whether to create missing parent directories. Defaults to `false`. ## Return value + A `Promise` that will resolve to the [`FSItem`](/Objects/fsitem) object of the moved file or directory. If the source file or directory does not exist, the promise will be rejected with an error. ## Examples diff --git a/src/FS/read.md b/src/FS/read.md index f3a6d11..2728366 100755 --- a/src/FS/read.md +++ b/src/FS/read.md @@ -7,13 +7,17 @@ platforms: [websites, apps, nodejs, workers] Reads data from a file. ## Syntax + ```js puter.fs.read(path) puter.fs.read(path, options) +puter.fs.read(options) ``` ## Parameters + #### `path` (String) (required) + Path of the file to read. If `path` is not absolute, it will be resolved relative to the app's root directory. @@ -21,13 +25,14 @@ If `path` is not absolute, it will be resolved relative to the app's root direct An object with the following properties: +- `path` (String) - Path to the file to read. Required when passing options as the only argument. - `offset` (Number) (optional) The offset to start reading from. - - `byte_count` (Number) (required if `offset` is provided) The number of bytes to read from the offset. ## Return value + A `Promise` that will resolve to a `Blob` object containing the contents of the file. ## Examples diff --git a/src/FS/readdir.md b/src/FS/readdir.md index 5d7a3fb..9e0211e 100755 --- a/src/FS/readdir.md +++ b/src/FS/readdir.md @@ -7,6 +7,7 @@ platforms: [websites, apps, nodejs, workers] Reads the contents of a directory, returning an array of items (files and directories) within it. This method is useful for listing all items in a specified directory in the Puter cloud storage. ## Syntax + ```js puter.fs.readdir(path) puter.fs.readdir(path, options) @@ -15,24 +16,20 @@ puter.fs.readdir(options) ## Parameters -#### `path` (string) -The path to the directory to read. -If `path` is not absolute, it will be resolved relative to the app's root directory. - - -#### `options` (object) (optional) +#### `path` (String) -
- -- `options.path` (string) (optional) The path to the directory to read. +If `path` is not absolute, it will be resolved relative to the app's root directory. -- `options.uid` (string) (optional) -The UID of the directory to read. +#### `options` (Object) (optional) +An object with the following properties: +- `path` (String) - The path to the directory to read. Required when passing options as the only argument. +- `uid` (String) (optional) - The UID of the directory to read. ## Return value + A `Promise` that resolves to an array of [`FSItem`](/Objects/fsitem/) objects (files and directories) within the specified directory. ## Examples diff --git a/src/FS/rename.md b/src/FS/rename.md index d9253be..744321d 100755 --- a/src/FS/rename.md +++ b/src/FS/rename.md @@ -7,19 +7,33 @@ platforms: [websites, apps, nodejs, workers] Renames a file or directory to a new name. This method allows you to change the name of a file or directory in the Puter cloud storage. ## Syntax + ```js puter.fs.rename(path, newName) +puter.fs.rename(options) ``` ## Parameters + #### `path` (string) + The path to the file or directory to rename. If `path` is not absolute, it will be resolved relative to the app's root directory. #### `newName` (string) + The new name of the file or directory. +#### `options` (Object) + +The options for the `rename` operation. The following options are supported: + +- `path` (String) - Path to the file or directory to rename. Required when passing options as the only argument. +- `uid` (String) - The UID of the file or directory to rename. Can be used instead of `path`. +- `newName` (String) - The new name for the file or directory. Required when passing options as the only argument. + ## Return value + Returns a promise that resolves to the [`FSItem`](/Objects/fsitem) object of the renamed file or directory. ## Examples diff --git a/src/FS/stat.md b/src/FS/stat.md index db24fc8..c2465a7 100755 --- a/src/FS/stat.md +++ b/src/FS/stat.md @@ -9,15 +9,30 @@ This method allows you to get information about a file or directory. ## Syntax ```js -puter.fs.stat(path) +puter.fs.stat(path, options) +puter.fs.stat(options) ``` ## Parameters -#### `path` (string) (required) + +#### `path` (String) (required) + The path to the file or directory to get information about. If `path` is not absolute, it will be resolved relative to the app's root directory. +#### `options` (Object) (optional) + +An object with the following properties: + +- `path` (String) - Path to the file or directory. Required when passing options as the only argument. +- `uid` (String) - The UID of the file or directory. Can be used instead of `path`. +- `returnSubdomains` (Boolean) - Whether to return subdomain information. Defaults to `false`. +- `returnPermissions` (Boolean) - Whether to return permission information. Defaults to `false`. +- `returnVersions` (Boolean) - Whether to return version information. Defaults to `false`. +- `returnSize` (Boolean) - Whether to return size information. Defaults to `false`. + ## Return value + A `Promise` that resolves to the [`FSItem`](/Objects/fsitem) object of the specified file or directory. ## Examples diff --git a/src/FS/upload.md b/src/FS/upload.md index c9fcc47..f966044 100755 --- a/src/FS/upload.md +++ b/src/FS/upload.md @@ -15,18 +15,27 @@ puter.fs.upload(items, dirPath, options) ``` ## Parameters -#### `items` (Array) (required) + +#### `items` (Object) (required) + The items to upload to the Puter filesystem. `items` can be an `InputFileList`, `FileList`, `Array` of `File` objects, or an `Array` of `Blob` objects. #### `dirPath` (String) (optional) + The path of the directory to upload the items to. If not set, the items will be uploaded to the app's root directory. #### `options` (Object) (optional) -A set of key/value pairs that configure the upload process. +A set of key/value pairs that configure the upload process. The following options are supported: + +- `overwrite` (Boolean) - Whether to overwrite the destination file if it already exists. Defaults to `false`. +- `dedupeName` (Boolean) - Whether to deduplicate the file name if it already exists. Defaults to `false`. +- `createMissingParents` (Boolean) - Whether to create missing parent directories. Defaults to `false`. ## Return value + Returns a `Promise` that resolves to: + - A single [`FSItem`](/Objects/fsitem/) object if `items` parameter contains one item - An array of [`FSItem`](/Objects/fsitem/) objects if `items` parameter contains multiple items diff --git a/src/FS/write.md b/src/FS/write.md index b7e83fe..f1c696b 100755 --- a/src/FS/write.md +++ b/src/FS/write.md @@ -12,23 +12,34 @@ Writes data to a specified file path. This method is useful for creating new fil puter.fs.write(path) puter.fs.write(path, data) puter.fs.write(path, data, options) +puter.fs.write(file) ``` ## Parameters -#### `path` (string) (required) + +#### `path` (String) (required) + The path to the file to write to. If path is not absolute, it will be resolved relative to the app's root directory. -#### `data` (string|File|Blob) +#### `data` (String|File|Blob) (required) + The data to write to the file. -#### `options` (object) +#### `options` (Object) + The options for the `write` operation. The following options are supported: + - `overwrite` (boolean) - Whether to overwrite the file if it already exists. Defaults to `true`. - `dedupeName` (boolean) - Whether to deduplicate the file name if it already exists. Defaults to `false`. - `createMissingParents` (boolean) - Whether to create missing parent directories. Defaults to `false`. +#### `file` (File) + +An alternative to `path` and `data`. A `File` object to write directly, where the file path will be derived from the file's name. + ## Return value + Returns a `Promise` that resolves to the [`FSItem`](/Objects/fsitem) object of the written file. ## Examples