copy
The copy
method can replicate the data of a specified key into another.
async function copy(
source: string,
target: string
): Promise<void>;
Reference
Overview
You can replicate the data of a specified source object into another target object by calling the copy
method.
import { myStorage } from "#elements";
...
await myStorage.copy("my-data/string.txt", "my-data/string1.txt");
...
Parameters
source
: A unique identifier string for the object being copied. This string should start and end with a letter or number, and the middle can contain letters, numbers, periods, slashes, hyphens, or underscores.target
: A unique identifier string for the new object. This string should start and end with a letter or number, and the middle can contain letters, numbers, periods, slashes, hyphens, or underscores.
Returns
The copy
method does not return any value.
Caveats
- An exception will be thrown if the source object does not exist.
- If the target object does not exist, a new one is created; otherwise, the value of the target object will be overwritten.