
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A simple wrapper to use browser File System Access API in a more convenient way.
npm install drive-fsa
Helper function to create a drive object from a directory handle
import { createDrive } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
const drive = createDrive(handle);
// list all files in the root directory
const entries = await drive.list('/');
// list all files in a subdirectory
const entries = await drive.list('/subdir1/subdir2');
// get individual file
const entry = await drive.get('/file.txt');
// read file, returns a Uint8Array
const uint8 = await drive.read('/file.txt');
// read file as text
const text = await drive.read('/file.txt', { contentType: 'text' });
// read file as json
const json = await drive.read('/file.txt', { contentType: 'json' });
// write to file Uint8Array
await drive.write('/file.txt', new TextEncoder().encode('Hello, World!'));
// write to file text
await drive.write('/file.txt', 'Hello, World!', { contentType: 'text' });
// write to file json
await drive.write('/file.txt', { hello: 'world' }, { contentType: 'json' });
// delete file
await drive.destroy('/file.txt');
Get an entry by path
import { findEntry } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
const entry = await findEntry(handle, '/file.txt');
List all entries in a directory
import { listEntries } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
const entries = await listEntries(handle, '/');
Read the content of a file
import { readEntry } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
const data = await readEntry(handle, '/file.txt'); // Promise<Uint8Array>
Use options to specify the content type
readEntry(handle, '/file.txt', { contentType: 'text' }); // Promise<string>
readEntry(handle, '/file.txt', { contentType: 'json' }); // Promise<Record<string, any>>
readEntry(handle, '/file.txt', { contentType: 'uint8array' }); // Promise<Uint8Array>
Create a directory
import { makeDirectoryEntry } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
await makeDirectoryEntry(handle, '/subdir1/subdir2');
Create a directory recursively
makeDirectoryEntry(handle, '/subdir1/subdir2', { recursive: true });
Write to a file
import { writeEntry, encode } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
await writeEntry(handle, '/file.txt', encode('Hello, World!'));
Use options to specify the content type
writeEntry(handle, '/file.txt', 'Hello, World!', { contentType: 'text' });
writeEntry(handle, '/file.txt', { hello: 'world' }, { contentType: 'json' });
writeEntry(handle, '/file.txt', new Uint8Array([1, 2, 3]), { contentType: 'uint8array' });
Recursive write
writeEntry(handle, '/subdir1/subdir2/file.txt', 'Hello, World!', { recursive: true });
Delete a file or a directory
import { destroyEntry } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
await destroyEntry(handle, '/file.txt');
Get a handle by path
Can be used to get a deep handle of a file or a directory
import { findHandle } from 'drive-fsa';
const handle = await window.showDirectoryPicker();
const fileHandle = await findHandle(handle, '/file.txt');
const dirHandle = await findHandle(handle, '/subdir1/subdir2');
FAQs
Wrapper for the File System Access API
The npm package drive-fsa receives a total of 1 weekly downloads. As such, drive-fsa popularity was classified as not popular.
We found that drive-fsa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.