big-file-stream
v1.0.10
Published
Copy file using streams from source to destination
Maintainers
Readme
Within the root of the project, copy any large big file from src directory to destination directory at ease using the copy function. UPDATE v 1.0.9: Minor bug fixes for copyFromHttp and updated Readme for more uses of copyFromHttp. see updated examples below: UPDATE v 1.0.8: New function copyFromHttp added. Signature: copyFromHttp = (url:string,{options:Object,data:string or Buffer or Uint8Array,fileName:string,secure:boolean}) Usage: By Default your request is sent over secure http connection: you can pass any http url here, the response will be saved in the fileName which is nothing but the last part of the url(in the below case its fileName.txt,1,allusers) copyFromHttp("https://exampledomain.com/fileName.txt"); copyFromHttp("https://exampledomain.com/api/1"); copyFromHttp("https://exampledomain.com/allusers"); if you want to override the fileName, you can give fileName key as second paramter like below: copyFromHttp("https://exampledomain.com/allusers",{fileName:"everyusers.java"}); download any software with exact download link of file: copyFromHttp("https://vscode.download.prss.microsoft.com/dbazure/download/stable/bf9252a2fb45be6893dd8870c0bf37e2e1766d61/VSCodeUserSetup-x64-1.106.3.exe",{fileName:"vscode.exe"}); For insecure connections: copyFromHttp("http://exampledomain.com/fileName.txt",{secure:false}); The last path value becomes the fileName and will be saved in root project directory as the same. For other than GET request, options parameter is mandatory. For post data, pass the "data" parameter. if it is json, you need to stringify it using JSON.stringify before passing the data. options parameter is same as the options paramter of http.request method in Node.js. Usage in app: import copy from "big-file-stream"; copy("data/anyexistingfile.txt","data1/data2/data3/newcopy.txt"); Signature of copy function: copy(sourceFilePath,destinationFilePath) Highlights: No dependencies Small 3Kb See live completed percentage, transfer speed and Time take to copy in console directly
Whats supported as of now: Support only copying single file in single call Avoids memory leak by closing both read and write stream on error
Future Update: Data streaming Multiple file streaming
Tested in Node js 20
