React Native
React Native
Split File into Chunks
Demonstrates how to split a file into chunks.Chilkat React Native Downloads
import { FileAccess } from '@chilkat/react-native'
function chilkatExample() {
const fac = new FileAccess();
// Any type of file may be split. It doesn't matter if it's
// a binary file or a text file.
const fileToSplit = 'qa_data/hamlet.xml';
const partPrefix = 'hamlet';
const partExtension = 'part';
const maxChunkSize = 50000;
const destDirPath = 'qa_output';
// Splits hamlet.xml into hamlet1.part, hamlet2.part, ...
// Output files are written to the current working directory.
// Each chunk will be 50000 bytes except for the last which
// will be the remainder.
try {
fac.splitFile(fileToSplit, partPrefix, partExtension, maxChunkSize, destDirPath);
console.log('Success.');
} catch {
console.log(fac.lastErrorText);
}
}