#101 list objects #103

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@kof
kof commented Oct 10, 2012

If this one is ok I will also add #listFiles.

@domenic

We need res.on('error', fn) too.

kof replied Oct 10, 2012

right.

@domenic

It'd be awesome to booleanize and numberize as necessary. E.g.

data.IsTruncated = Boolean(data.IsTruncated);
data.MaxKeys = Number(data.MaxKeys);
data.Contents.forEach(function (object) {
    object.Size = Number(object.Size);
    object.LastModified = new Date(object.LastModified);
});
kof replied Oct 10, 2012

any Ideas how to make it generic and not too slow?

Hmm, not really. But I think since we know the possible keys returned, just explicitly fixing them on a case-by-case basis is OK.

@domenic

Don't update the version in a pull request, I'll do that when I do a release :)

@domenic

You'll probably want to add these to the multiple-delete test to try and clean up.

kof replied Oct 10, 2012

I think tests should be independent from each other, so I can just clean them up

Good point.

@domenic

This is a nice test; well done.

@domenic

It's not really res (which I would expect to be a HTTP response object); it's more like data I think.

@domenic
domenic commented Oct 10, 2012

Very nicely done. I left a bunch of little comments but I look forward to merging this. Feel free to amend last commit and force-push.

@kof kof commented on the diff Oct 10, 2012
test/knox.test.js
+
+ client.putFile(jsonFixture, files[0], function(err, res){
+ client.putFile(jsonFixture, files[1], function(err, res){
+ client.list({prefix: 'list'}, function(err, data){
+ assert.ok(!err);
+ assert.equal(data.Prefix, 'list');
+ assert.strictEqual(data.IsTruncated, true);
+ assert.strictEqual(data.MaxKeys, 1000);
+ assert.equal(data.Contents.length, 2);
+ assert.ok(data.Contents[0].LastModified instanceof Date);
+ assert.equal(typeof data.Contents[0].Size, 'number');
+ assert.deepEqual(
+ Object.keys(data.Contents[0]),
+ ['Key', 'LastModified', 'ETag', 'Size', 'Owner', 'StorageClass']
+ );
+ client.deleteMultiple(files, function(err, res) {
@kof
kof Oct 10, 2012

it will never get to this callback, err == null, res.statusCode == 200 ....

do you have the same issue?

@domenic
domenic Oct 10, 2012

No, it's not hanging at all for me... test passes perfectly.

@kof
kof commented Oct 10, 2012

Everything is done except of hanging on ln 354 in knox.test.js

@domenic
domenic commented Oct 10, 2012

I'm ready to merge, since it passes for me and the tests have been flaky for you (which I still really want to fix :-/). Love the normalizeResponse function; very clever. Any last-minute changes you want to make?

@kof
kof commented Oct 10, 2012

No :)

@domenic domenic added a commit that closed this pull request Oct 10, 2012
@kof kof Add `client#list()` to list all objects in a bucket.
Closes #101, closes #103.
c8a8631
@domenic domenic closed this in c8a8631 Oct 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment