
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
@semantq/storage
Advanced tools
File storage module for semantqQL — the Node.js backend of the semantq framework.
File storage module for semantqQL — the Node.js backend of the semantq framework.
Organizes files by model record structure (e.g., product/1/images/) and provides a unified API across multiple storage providers.
npm install @semantq/storage
import { Storage } from '@semantq/storage';
// Upload a file (from multer, Buffer, or File object)
const result = await Storage.upload(fileBuffer, {
organizationId: 1,
modelName: 'ProjectFile',
recordId: 'abc-123',
fieldKey: 'fileUrl',
originalName: 'document.pdf',
mimeType: 'application/pdf'
});
// result: { storageKey, publicUrl, fileSize, fileHash, metadata }
// Get a public URL
const url = await Storage.getUrl(result.storageKey);
// Check if file exists
const exists = await Storage.exists(result.storageKey);
// Get file as buffer
const buffer = await Storage.getBuffer(result.storageKey);
// Delete file
await Storage.delete(result.storageKey);
Storage.upload(file, metadata)Upload a file. Accepts a Buffer, multer file object, or browser File instance.
| Option | Type | Required | Description |
|---|---|---|---|
organizationId | string/number | Yes | Organization ID |
modelName | string | Yes | Model name (e.g., ProjectFile, Budget) |
recordId | string | Yes | Record UUID |
fieldKey | string | Yes | Field name (e.g., fileUrl) |
originalName | string | No | Original filename |
mimeType | string | No | File MIME type |
Returns: { storageKey, publicUrl, fileSize, fileHash, metadata }
Storage.delete(storageKey)Delete a file from storage. Returns boolean.
Storage.getUrl(storageKey)Get the public URL for a file. Returns string.
Storage.getBuffer(storageKey)Download file as a Buffer. Returns Buffer.
Storage.exists(storageKey)Check if file exists in storage. Returns boolean.
Files are stored with a structured path pattern:
{organizationId}/{modelName}/{recordId}/{fieldKey}/{filename}
Example:
1/projectfile/abc-123/fileurl/document_1711234567890_a1b2c3.pdf
Stores files on the local filesystem. Configure in server.config.js:
storage: {
activeProvider: 'local',
local: {
uploadDir: './uploads',
baseUrl: '/uploads'
}
}
Cloud storage via UploadThing. Falls back to local provider when no token is configured.
AWS S3 provider.
Cloudinary provider.
All storage configuration lives in your SemantQQL server.config.js under the storage key:
export default {
storage: {
activeProvider: 'local', // 'local' | 'uploadthing' | 's3' | 'cloudinary'
local: {
uploadDir: './uploads',
baseUrl: '/uploads'
},
uploadthing: {
token: process.env.UPLOADTHING_TOKEN,
appId: process.env.UPLOADTHING_APP_ID
}
// s3: { ... } (coming soon)
// cloudinary: { ... } (coming soon)
}
}
import { Storage } from '@semantq/storage';
class ProjectFileService {
async uploadFile(req) {
const file = req.file;
const userData = req.userData;
const result = await Storage.upload(file, {
organizationId: userData.organizationId,
modelName: 'ProjectFile',
recordId: req.body.projectId,
fieldKey: 'fileUrl',
originalName: file.originalname,
mimeType: file.mimetype
});
// Save result.storageKey and result.publicUrl to your database
await ProjectFileModel.create({
filename: file.originalname,
fileUrl: result.publicUrl,
fileKey: result.storageKey,
// ... other fields
});
}
async deleteFile(fileId) {
const file = await ProjectFileModel.findById(fileId);
if (file?.fileKey) {
await Storage.delete(file.fileKey);
}
await ProjectFileModel.delete(fileId);
}
}
To add a new provider, extend BaseStorageProvider:
import { BaseStorageProvider } from '@semantq/storage';
class MyProvider extends BaseStorageProvider {
constructor(config) {
super(config);
this.name = 'myprovider';
}
async upload(fileBuffer, options) { /* ... */ }
async delete(storageKey) { /* ... */ }
async getUrl(storageKey) { /* ... */ }
async exists(storageKey) { /* ... */ }
async getBuffer(storageKey) { /* ... */ }
}
MIT
FAQs
File storage module for semantqQL — the Node.js backend of the semantq framework.
We found that @semantq/storage 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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.