### startWriteStream, writeChunk, endWriteStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Manages writing data to an SAF file using a stream-based approach. This involves starting a write session, writing data in chunks, and then closing the session. ```APIDOC ## Write File Stream ### Description Manages writing data to an SAF file using a stream-based approach. This involves starting a write session, writing data in chunks, and then closing the session. ### Methods - `startWriteStream` - `writeChunk` - `endWriteStream` ### `startWriteStream` Parameters #### Path Parameters - **`'SAF directory URI '`** (string) - Required - The URI of the SAF directory. - **`''`** (string) - Required - The URI of the SAF file to write to. - **`'text/plain'`** (string) - Required - The MIME type of the file. ### `startWriteStream` Response #### Success Response (200) - **`info`** (object) - Contains session information. - **`sessionID`** (string) - The ID for the write session. ### `writeChunk` Parameters #### Path Parameters - **`sessionID`** (string) - Required - The ID of the write session. - **`utf8.encode('block 1')`** (List) - Required - The data chunk to write. ### `endWriteStream` Parameters #### Path Parameters - **`sessionID`** (string) - Required - The ID of the write session to close. ### Request Example ```dart // Create a session. final info = await _safStreamPlugin.startWriteStream('SAF directory URI ', '', 'text/plain'); final sessionID = info.session; // Write chunk with a session ID. await _safStreamPlugin.writeChunk(sessionID, utf8.encode('block 1')); // Write another chunk. await _safStreamPlugin.writeChunk(sessionID, utf8.encode('block 2')); // Close the stream. await _safStreamPlugin.endWriteStream(sessionID); ``` ``` -------------------------------- ### Write File Stream with SafStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Use this method for writing large files to SAF by breaking the data into chunks. It involves starting a write session, writing multiple chunks, and then ending the session. ```dart // Create a session. final info = await _safStreamPlugin.startWriteStream('SAF directory URI ', '', 'text/plain'); final sessionID = info.session; // Write chunk with a session ID. await _safStreamPlugin.writeChunk(sessionID, utf8.encode('block 1')); // Write another chunk. await _safStreamPlugin.writeChunk(sessionID, utf8.encode('block 2')); // Close the stream. await _safStreamPlugin.endWriteStream(sessionID); ``` -------------------------------- ### pasteLocalFile Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Pastes a local file into a specified SAF directory. ```APIDOC ## pasteLocalFile ### Description Pastes a local file into a specified SAF directory. ### Method `pasteLocalFile` ### Parameters #### Path Parameters - **``** (string) - Required - The URI of the SAF directory to paste the file into. - **``** (string) - Required - The path of the local file to paste. ### Response #### Success Response (200) - **`void`** - Indicates successful completion. ### Request Example ```dart await _safStreamPlugin.pasteLocalFile('', ''); ``` ``` -------------------------------- ### startReadCustomFileStream, readCustomFileStreamChunk, skipCustomFileStreamChunk, endReadCustomFileStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Advanced read APIs for custom file stream operations, allowing skipping bytes on the native side. ```APIDOC ## Advanced Read APIs ### Description Advanced read APIs for custom file stream operations, allowing skipping bytes on the native side instead of on the Dart side using `readFileStream`. ### Methods - `startReadCustomFileStream` - `readCustomFileStreamChunk` - `skipCustomFileStreamChunk` - `endReadCustomFileStream` ### `startReadCustomFileStream` Parameters #### Path Parameters - **``** (string) - Required - The URI of the SAF file. ### `readCustomFileStreamChunk` Parameters #### Path Parameters - **``** (int) - Required - The size of the chunk to read. ### `skipCustomFileStreamChunk` Parameters #### Path Parameters - **``** (int) - Required - The size of the chunk to skip. ### `endReadCustomFileStream` Parameters #### Path Parameters - None ### Response (for read/skip operations) #### Success Response (200) - **`List`** - A chunk of data read from the file, or an empty list if the end of the file is reached. ### Request Example (Conceptual) ```dart // Assuming these methods are called sequentially to manage a custom read stream // final session = await _safStreamPlugin.startReadCustomFileStream(''); // final chunk = await _safStreamPlugin.readCustomFileStreamChunk(session, 1024); // await _safStreamPlugin.skipCustomFileStreamChunk(session, 512); // await _safStreamPlugin.endReadCustomFileStream(session); ``` ``` -------------------------------- ### copyToLocalFile Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Copies an SAF file to a local file path on the device. ```APIDOC ## copyToLocalFile ### Description Copies an SAF file to a local file path on the device. ### Method `copyToLocalFile` ### Parameters #### Path Parameters - **``** (string) - Required - The URI of the SAF file to copy. - **``** (string) - Required - The destination path for the local file. ### Response #### Success Response (200) - **`void`** - Indicates successful completion. ### Request Example ```dart await _safStreamPlugin.copyToLocalFile('', ''); ``` ``` -------------------------------- ### writeFileBytes Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Writes a list of bytes to a new file within an SAF directory. Supports overwriting and appending. ```APIDOC ## writeFileBytes ### Description Writes a list of bytes to a new file within an SAF directory. Supports overwriting and appending. ### Method `writeFileBytes` ### Parameters #### Path Parameters - **``** (string) - Required - The URI of the SAF directory where the file will be created. - **`'file.txt'`** (string) - Required - The name of the file to create. - **`'text/plain'`** (string) - Required - The MIME type of the file. - **`utf8.encode('Hello, World!')`** (List) - Required - The data to write to the file. - **`overwrite`** (bool) - Optional - If true, overwrites the file if it exists. - **`append`** (bool) - Optional - If true, appends to the file if it exists. ### Response #### Success Response (200) - **`void`** - Indicates successful completion. ### Request Example ```dart await _safStreamPlugin.writeFileBytes( '', 'file.txt', 'text/plain', utf8.encode('Hello, World!') ); ``` ``` -------------------------------- ### Write File Bytes with SafStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Use this method to write a list of bytes to a new file within an SAF directory. Specify the destination directory, file name, MIME type, and the data to write. Supports overwrite and append options. ```dart await _safStreamPlugin.writeFileBytes( // Dest SAF directory URI. '', // Dest file name. 'file.txt', // MIME type. 'text/plain', // Data to write. utf8.encode('Hello, World!') ); ``` -------------------------------- ### Read File Stream with SafStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Use this method to read the content of an SAF file as a stream of byte lists. This is recommended for large files to manage memory efficiently. ```dart Stream> fileStream = await _safStreamPlugin.readFileStream(''); ``` -------------------------------- ### Read File Bytes with SafStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Use this method to read the entire content of an SAF file into a list of bytes. Suitable for smaller files where memory is not a concern. ```dart import 'package:saf_stream/saf_stream.dart'; final _safStreamPlugin = SafStream(); // Read file bytes. List fileBytes = await _safStreamPlugin.readFileBytes(''); ``` -------------------------------- ### readFileBytes Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Reads the entire content of an SAF file into a list of bytes. Suitable for small files or when memory is not a concern. ```APIDOC ## readFileBytes ### Description Reads the entire content of an SAF file into a list of bytes. ### Method `readFileBytes` ### Parameters #### Path Parameters - **``** (string) - Required - The URI of the SAF file to read. ### Response #### Success Response (200) - **`List`** - The content of the file as a list of bytes. ### Request Example ```dart List fileBytes = await _safStreamPlugin.readFileBytes(''); ``` ``` -------------------------------- ### readFileStream Source: https://github.com/flutter-cavalry/saf_stream/blob/main/README.md Reads an SAF file as a stream of byte chunks. Ideal for large files to manage memory efficiently. ```APIDOC ## readFileStream ### Description Reads an SAF file as a stream of byte chunks. Ideal for large files to manage memory efficiently. ### Method `readFileStream` ### Parameters #### Path Parameters - **``** (string) - Required - The URI of the SAF file to read. ### Response #### Success Response (200) - **`Stream>`** - A stream emitting chunks of the file's content. ### Request Example ```dart Stream> fileStream = await _safStreamPlugin.readFileStream(''); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.