Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
files.com
Advanced tools
Readme
The Files.com JavaScript SDK provides convenient access to the Files.com API from applications written in JavaScript.
To install the package:
yarn add files.com
or
npm install files.com
import Files from "files.com/lib/Files.js";
// set your subdomain or custom domain
Files.setBaseUrl("https://MY-SUBDOMAIN.files.com");
require()
vs. import
The examples provided in the documentation here use the newer ES6 import
syntax. To
instead use the older CommonJS module syntax with require()
, ensure that .default
is included. For example:
const Files = require("files.com/lib/Files.js").default;
const User = require("files.com/lib/models/User.js").default;
// destructure to directly assign a named export
const { LogLevel } = require("files.com/lib/Logger.js").default;
There are multiple ways to authenticate to the Files.com SDK for Javascript.
You can set an API key globally like this:
Files.setApiKey('my-api-key')
Or, you can pass an API key per-request, in the options object at the end of every method like this:
import User from 'files.com/lib/models/User.js'
const user = new User(params, { apiKey: 'my-api-key' })
Or, you can open a user session by calling Session.create()
import Session from 'files.com/lib/models/Session.js'
const session = await Session.create({ username, password })
Then use it globally for all subsequent API calls like this:
Files.setSessionId(session.id)
Or, you can pass the session ID per-request, in the options array at the end of every method like this:
import User from 'files.com/lib/models/User.js'
const user = new User(params, { sessionId: session.id })
You can set the following global properties using static methods on the Files
class:
import { LogLevel } from 'files.com/lib/Logger.js'
Files.setLogLevel(LogLevel.INFO)
/*
Call Files.setLogLevel() with one of the following:
LogLevel.NONE
LogLevel.ERROR
LogLevel.WARN
LogLevel.INFO (default)
LogLevel.DEBUG
*/
Files.configureDebugging({
// enable debug logging of API requests (default: false)
debugRequest: false,
// enable debug logging of API response headers (default: false)
debugResponseHeaders: false,
})
Files.configureNetwork({
// max retries (default: 3)
maxNetworkRetries: 3,
// minimum delay in seconds before retrying (default: 0.5)
minNetworkRetryDelay: 0.5,
// max delay in seconds before retrying (default: 1.5)
maxNetworkRetryDelay: 1.5,
// network timeout in seconds (default: 30.0)
networkTimeout: 30.0,
// auto-fetch all pages when results span multiple pages (default: `true`)
autoPaginate: true,
})
import Folder from 'files.com/lib/models/Folder.js'
const dirFiles = await Folder.listFor('/')
import File from 'files.com/lib/models/File.js'
import { isBrowser } from 'files.com/lib/utils.js'
// uploading raw file data
await File.uploadData(destinationFileName, data)
// uploading a file on disk (not available in browser)
if (!isBrowser()) {
await File.uploadFile(destinationFileName, sourceFilePath)
}
import File from 'files.com/lib/models/File.js'
const foundFile = await File.find(remoteFilePath)
const downloadableFile = await foundFile.download()
import { isBrowser } from 'files.com/lib/utils.js'
if (!isBrowser()) {
// download to a file on disk
await downloadableFile.downloadToFile(localFilePath)
// download to a writable stream
await downloadableFile.downloadToStream(stream)
// download in memory and return as a UTF-8 string
const textContent = await downloadableFile.downloadToString()
}
For related documentation see Case Sensitivity Documentation.
import { pathNormalizer } from 'files.com/lib/utils.js'
if (pathNormalizer.same('Fïłèńämê.Txt', 'filename.txt')) {
// the paths are the same
}
Additional docs are available at https://developers.files.com
The Files.com team is happy to help with any SDK Integration challenges you may face.
Just email support@files.com and we'll get the process started.
FAQs
Files.com SDK for JavaScript
The npm package files.com receives a total of 23,920 weekly downloads. As such, files.com popularity was classified as popular.
We found that files.com demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.