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);
}
Hi,
Currently I have a request stream and I pass that stream to node-cloudfiles'
addFileascloudfile.addFile("container", "{remote: "fileName.ext", stream: readStream}, callback)However, since the request stream has
content-typeset toapplication/octet-stream, it is saved asapplication/octet-streamin Rackspace.From
core.js:addFile:Understandably, it will only try to look up MIME type when
options.headersis set, so for my above code to work, I would include aheaders: {}in theoptionsargument.My question is, I'm not sure why it only tries to detect when
options.headersis 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:addFilecause any problem?