File parameters #598
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hey. I would like to know, if I can pass parameters within uploaded file?
I have
And I need to save Attachment object with image file as field, not only image itself.
How can I do that?
Thank you.
I'm also having issues with additional parameters I noticed that there is formdata attribute but no way to add additional parameters.
+1
+1
Anyone have a solution?
Alternate library for this solution https://github.com/babarxm/ng-uploader
Needed this scenario today. Doing some debugging, I found this code in the
file-uploader.class(line ~234):So if you do not disable the multipart, you can pass
additionalParameterto the FileUploader:If I understand your issue correctly, the
onBuildItemFormextension point should do the job (mentioned here):I've been able to successfully add parameters to the POST request that way. Just declare it once when you create
uploader. Of course'another_value'can be a function call or a form value, eg.this.form.get('another_field').value@loiane
Hi Loiane, I am trying to add parameters like you mention but how do I make sure the Multipart is not disabled, as in my vs code if I use your example it highlights additionalParameter in red and says
"Argument of type '{ url: string; additionalParameter: { comments: string; }; }' is not assignable to parameter of type 'FileUploaderOptions'.
Object literal may only specify known properties, and 'additionalParameter' does not exist in type 'FileUploaderOptions'."
What have I missed, if you look at issue 905 you can see what I am trying to achieve.
Thanks
Andy
Found the solution in issue #673
public uploader: FileUploader = new FileUploader({
url: this.URL,
additionalParameter: {
comments: 'sdfsfsdfsdfsdfsdf'
}
});
how to access the additionalParameter from nodejs??
@pnramya
And I'm using snippet on client-side:
@pnramya
Or
console.log(req.body)gives me an empty object. @inovozenko do you know why? may be I miss something?@noemi-dresden Hi
First of all you should send some param on client-side:
form.append('my-param', 'my-value');And then receive it on NodeJS-side:
upload(req, res, function (error) { console.log(req.body); // <- here your params });@inovozenko thx for the quick reply,
That's was, what I've done and then I got
{}, I could see my params while console.log on the client side browser thoughtI was trying this as well but it doesn't work
When I console.log(this.uploader), I can see the additional parameter under
optionsthe solution for this prblm is:
uploader:FileUploader = new FileUploader({url:uri,
authTokenHeader: 'authorization',
authToken: localStorage.getItem('token'),
additionalParameter: { 'name': 'my data'}
});
upload(req, res, function(err){
In definition of FileUploader I used : itemAlias
new FileUploader({ url: URL, itemAlias: 'image' });