Skip to content
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

Pass contentType from .write to form.append #4

Open
amurchick opened this issue Jul 19, 2016 · 1 comment
Open

Pass contentType from .write to form.append #4

amurchick opened this issue Jul 19, 2016 · 1 comment

Comments

@amurchick
Copy link

Sometime needs direct assign of content-type when write file to seaweedfs.

To do this - simply change line https://github.com/atroo/node-weedfs/blob/master/lib/weedfs.js#L83:

form.append("file", stream ? stream : file[i]);

to:

form.append("file", stream ? stream : file[i], opts);

And this allowed assign content-type like this:

weed.write('./file', {contentType: 'image/png'})
@phal0r
Copy link
Collaborator

phal0r commented Jul 20, 2016

Hi @amurchick ,

what is your scenario for submitting the contentType to weed?

Since an array can be passed to the write function, the general options which are appended as querystring to be send to weed are the wrong place. A cleaner solution would be to pass an object instead of a plain buffer like so:

weed.write({
    file: buffer or path or stream,
    contentType: 'image/png'
});

Then we could also support filename and knownLength options provided by form-append

{
    filename: 'unicycle.jpg',
    contentType: 'image/jpg',
    knownLength: 19806
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants