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

Add support for custom FormData #12

Closed
safrazik opened this issue Sep 12, 2019 · 3 comments
Closed

Add support for custom FormData #12

safrazik opened this issue Sep 12, 2019 · 3 comments

Comments

@safrazik
Copy link
Owner

safrazik commented Sep 12, 2019

As discused in: #5

Proposed API:

// Upload with custom FormData
this.$refs.vueFileAgent.upload(url, headers, filesData, function createFormData(fileData){
  var formData = new FormData();
  formData.append('action', 'upload');
  formData.append('my-file', fileData.file); // this is important! - the actual file for upload
  return formData; // edit: fixed. Thanks to Chauhan-Nitesh for the comment below
});
@safrazik safrazik added this to the 1.2 Yellow Canary milestone Sep 12, 2019
@Chauhan-Nitesh
Copy link

@safrazik First of all I want to thanks for such a useful plugin.

You missed the return statement in code.
return formData;

Otherwise the post data will empty while uploading the file.

@safrazik
Copy link
Owner Author

Thanks for the appreciation and thanks for pointing out the issue . Fixed the example. The library code is already fine with it.

if(typeof createFormData == 'function'){
  formData = createFormData(fileData);
}
else {
  formData = new FormData();
  formData.append('file', fileData.file);
}

@abelnexus
Copy link

formData.append('id', this.id);
why add dinamic id error undefined 'id'

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

3 participants