-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes fs.js s3 read/write issues introduced by switching clients #282
Conversation
- Stripped leading slashes in object paths supplied to fs functions to be more consistent with expected fs behavior (as well as the older s3fs-based implementation) - Changed s3_readFile() to return a Promise<Buffer> by default and only returns a string if the user specifies an encoding. Additionally, an empty body results in a Promise<Void> rather than an empty string.
c7d050b
to
311f018
Compare
return new Promise((resolve, reject) => { | ||
const stream = data.Body; | ||
const chunks = []; | ||
stream.on('data', chunk => chunks.push(chunk)) | ||
stream.once('end', () => resolve(Buffer.concat(chunks))) | ||
stream.once('error', reject) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: make this reusable? Looks similar to steamToString as well but maybe nothing to pull out between the 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple enough. I hadn't even looked at the content of streamToString
.
ed2edce
to
0041cc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good except the backwards compat question
@@ -123,7 +127,7 @@ async function s3_readFile(...args) { | |||
async function s3_readdir(path) { | |||
const bucketParams: ListObjectsCommandInput = { | |||
Bucket: bucketName, | |||
Prefix: `${path}`, | |||
Prefix: stripLeadingSlashes(`${path}`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this really used to be the behaviour? If so, we broke backwards compat, then we'll be breaking backwards compat again to return it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual behavior was actually quite a bit more complex as seen here:
https://github.com/hasnat/s3fs/blob/master/lib/utils.js
The key bit is that all the keys were normalized across host operating systems to match a specific format. Removing that from our FS breaks the expectation that you can use the Cloud FS the same as your local FS.
|
Resolves #280
Standard checks
v0.6.1
that using Cloud FS for JavaScript that intend to use/
as an actual s3 object prefix or that expectfs.readFile()
to always return a string.