Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ Bucket.prototype.delete = function(callback) {
* var file = bucket.file('my-existing-file.png');
*/
Bucket.prototype.file = function(name) {
if (!name) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

throw Error('A file name must be specified.');
}

return new File(this, name);
};

Expand Down
4 changes: 0 additions & 4 deletions lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ var STORAGE_UPLOAD_BASE_URL = 'https://www.googleapis.com/upload/storage/v1/b';
* @constructor
*/
function File(bucket, name, metadata) {
if (!name) {
throw Error('A file name must be specified.');
}

this.bucket = bucket;

This comment was marked as spam.

this.makeReq_ = bucket.makeReq_.bind(bucket);
this.metadata = metadata || {};
Expand Down
8 changes: 6 additions & 2 deletions test/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ describe('Bucket', function() {
var file;
var metadata = { a: 'b' };

beforeEach(function() {
file = bucket.file(FILE_NAME, metadata);
it('should throw if no name was provided', function() {
assert.throws(function() {
file = bucket.file();

This comment was marked as spam.

}, /A file name must be specified./);

This comment was marked as spam.

});

it('should return a File object', function() {
file = bucket.file(FILE_NAME, metadata);
assert(file instanceof FakeFile);
});

it('should pass filename to File object', function() {
file = bucket.file(FILE_NAME, metadata);
assert.equal(file.name, FILE_NAME);
});
});
Expand Down
6 changes: 0 additions & 6 deletions test/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ describe('File', function() {
});

describe('initialization', function() {
it('should throw if no name is provided', function() {
assert.throws(function() {
new File(bucket);
}, /A file name must be specified/);
});

it('should assign file name', function() {
assert.equal(file.name, FILE_NAME);
});
Expand Down