Skip to content

Commit

Permalink
empty folder paths are allowed for s3
Browse files Browse the repository at this point in the history
  • Loading branch information
ricsam committed Mar 7, 2020
1 parent 68545ea commit f0662d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ example
dist
nodemon.json
tslint.json
.prettierrc
.github
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { nafs, expressMiddleware } = require('nafs');
const express = require('express');

const localFs = nafs('file:///tmp/dev_storage');
const remoteFs = nafs('s3:///key:secret@bucket_name/some/path/in/bucket');
const remoteFs = nafs('s3:///key:secret@us-east-1/bucket_name/some/path');

const app = express();

Expand All @@ -34,7 +34,7 @@ app.get('/read', (req, res) => {

### Enable cache for remote data
```js
const remoteFs = nafs('s3:///key:secret@bucket_name/some/path?cacheDir=/tmp/images');
const remoteFs = nafs('s3:///key:secret@us-east-1/bucket_name?cacheDir=/tmp/images');

console.time('hello');
remoteFs.readFile('/hello').then(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/nafs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const activeStorageS3Serve: NAFSFactory = (url) => {
| 'cache-only'
| 'no-cache' = 'cache-first';
const r = url.match(
/^s3:\/\/([^:]+):([^@]+)@([^/]+)\/([^/]+)\/([^?]+)(\?.+)?$/
/^s3:\/\/([^:]+):([^@]+)@([^/]+)\/([^/?]+)\/?([^?]*)(\?.+)?$/
);

if (r) {
Expand Down Expand Up @@ -137,7 +137,6 @@ const activeStorageS3Serve: NAFSFactory = (url) => {
resolve();
});
fstream.once('error', (err) => {
console.log('rejecting here');
reject(err);
});
});
Expand Down

0 comments on commit f0662d5

Please sign in to comment.