-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Hi,
Currently I have a request stream and I pass that stream to node-cloudfiles' addFile as
cloudfile.addFile("container", "{remote: "fileName.ext", stream: readStream}, callback)
However, since the request stream has content-type set to application/octet-stream, it is saved as application/octet-stream in Rackspace.
From core.js:addFile:
addOptions = {
method: 'PUT',
client: this,
upload: lstream,
uri: this.storageUrl(container, options.remote),
headers: options.headers || {}
};
if (options.headers && !options.headers['content-type']) {
options.headers['content-type'] = mime.lookup(options.remote);
}Understandably, it will only try to look up MIME type when options.headers is set, so for my above code to work, I would include a headers: {} in the options argument.
My question is, I'm not sure why it only tries to detect when options.headers is set. I, for one, would not want to do any thing with the request headers, yet still want the MIME to be look up immediately.
Would changing to the below in core.js:addFile cause any problem?
addOptions = {
method: 'PUT',
client: this,
upload: lstream,
uri: this.storageUrl(container, options.remote),
headers: options.headers || {}
};
if (!addOptions.headers['content-type']) {
addOptions.headers['content-type'] = mime.lookup(options.remote);
}