Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
files-repo
Advanced tools
Readme
Node.js files manager module for easy management of files repository in projects.
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Tested on 10.x Node.js node version.
Installation is done using npm install
command:
$ npm install files-repo
const FilesManager = require("files-repo");
let f = FilesManager( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
Where:
Adds an existing file located at 'pathToFile'. If fileId is provided, then will be used as file ID for that existing file.
Returns the file ID for the new file added.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileId = await f.AddExistingFile( Path.join( PATH_TO_SAMPLE_FILES, "testfile01.txt" ) );
Assert.equal( fileId.length, 32 );
Adds a new file from a buffer.
Returns the file ID for the new file added.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
Assert.equal( fileId.length, 32 );
Reads a file given its file ID.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
let fileRead = await f.ReadFile( fileId );
Assert.isTrue( fileBuffer.equals(fileRead) );
Checks if a file exists given its file ID
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
let exists = await f.ExistsFile( fileId );
Assert.isTrue( exists );
Removes file given its file ID
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
await f.DeleteFile( fileId );
Gets the JSON file manifest.
This JSON object has this self description properties using one real sample:
{
"fileId": "3598af972306401b925ef163dfa649b3",
"length": 21,
"extension": "bin",
"created": "2019-10-14T07:50:22.945Z",
"location": "/home/rgb/dev/projects/files/test/testfilesrepository/dfa649b3/3598af972306401b925ef163dfa649b3.bin" }
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
let fileManifest = await f.GetFileManifest( fileId );
Iterates by all files in the repository and performs one call by file to fnc function with their filemanifests.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let filesRead = 0;
let callback = async function( fileManifest ) { filesRead++; }
await f.IterateAll( callback );
Assert.isTrue( filesRead > 0 );
FAQs
Files manager module for easy files managemente in a NodeJS project
The npm package files-repo receives a total of 8 weekly downloads. As such, files-repo popularity was classified as not popular.
We found that files-repo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.