googlicius / file-storage Goto Github PK
View Code? Open in Web Editor NEWA file system abstraction for Node.js.
License: MIT License
A file system abstraction for Node.js.
License: MIT License
Expected url return a string because it's defined as typescript.
uniqueFileName not respected when calling Storage.disk(...)
When setting the uniqueFileName global to true:
Storage.config<BuiltInDiskConfig>({
uniqueFileName: true,
defaultDiskName: 'local',
diskConfigs: [
{
driver: DriverName.LOCAL,
name: 'local',
root: 'media'
}
]
});
The internal default disk works fine, we get the unique file with extension .txt
:
await Storage.put(Buffer.from("I am a unique one."), "asd.txt");
However, when calling the disk getter, the setting is not applied:
await Storage.disk('local').put(Buffer.from("I will overwrite asd.txt"), "asd.txt");
Could be an easy fix!
When I add the dependency @file-storage/common
using yarn
it fails with this message:
error /app/node_modules/@file-storage/common/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /app/node_modules/@file-storage/common/node_modules/sharp
Output:
sharp: Installation error: Invalid Version: 1.2.4_git20230717
According to this issue this sharp
problem has been fixed at version 0.29, but the common
package still references 0.28
.
Would it be possible to upgrade to at least 0.29 ? I can open a pull request if you want.
Beside, why is sharp
even required ? Image stats fetching could be done within an extra package like @file-storage/image
. Also, maybe extracting metadata using node-imagemagick
could be a solid alternative as it relies on top of imagemagick
command that is pretty standard on debian-based distros. Anyway, these are just suggestions :)
However, and because this issue blocks my current development, I'm afraid I'll give a try to storage-abstraction
instead :/
Request module was so popular, but now it's deprecated so need to add it as dependency.
I'm working on an application that uses ES2022 modules. So I've set "type": "module"
in package.json
and the TypeScript settings are "target": "ES2022", "module": "ES2022"
.
I'm experiencing the following issue:
When I import the Storage class like this and run it I get an error:
import Storage from '@file-storage/core';
Storage.config({});
Error:
Storage.config({});
^
TypeError: Storage.config is not a function
There are currently two workaround I have found:
(Storage as any).default.config({});
import { Storage } from '@file-storage/core/dist/file-storage.js';
It's also possible to get a proper import by downgrading the whole application to CommonJS module (remove "type": "module"
from package.json
and set "module": "CommonJS"
in tsconfig.json
), but I can't do that as other packages only work in a ESNext module.
I've created a minimal sample to reproduce the issue: https://github.com/sr258/file-storage-minimal-sample
Steps to reproduce:
npm install
npm build
npm run start:error
It looks like way the class is exported doesn't work with a fully ES2022 module.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.