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

Perform action before file upload #59

Closed
mastarenee opened this issue Jun 8, 2017 · 2 comments · Fixed by #101
Closed

Perform action before file upload #59

mastarenee opened this issue Jun 8, 2017 · 2 comments · Fixed by #101
Assignees
Milestone

Comments

@mastarenee
Copy link

Is it possible that after the user has selected an image I can call an (onBeforeUpload) function to run edits on the image using ng2-pica. If not can I remove the URL so the file doesn't upload but then after I've performed my edits get your plugin to make a call to the server with a URL I would provide it with?

@shangab
Copy link

shangab commented Jun 13, 2017

This is very important @mastarenee , for example I have a one PHP back end file to handle uploads of different types of images (Cars, students, ...ect). I want to stash other POST prams to be used in my back end PHP? what can I do?? a call back such as:

OnBeforeUpload ($params){
      $params.push({type:xyz, folder:abc...etc});
}

is very important

@UncleDave UncleDave self-assigned this Jun 22, 2017
@UncleDave
Copy link
Collaborator

UncleDave commented Jun 22, 2017

How does the following signature sound:

onBeforeUpload: (files: FileList) => boolean | FileList | Promise<boolean> | Promise<FileList>

onBeforeUpload will be called when images are selected/dropped, the list of files will be passed into this function. Return a boolean or a promise that resolves to a boolean to continue (true) or abort (false). Alternatively return a modified FileList (or promise) containing the files to continue with.

Or perhaps the return value of the function could be an object with more things in it, if there's a requirement:

{
  files: FileList,
  queryParams: Map<string, string>,
  url: string
}

@UncleDave UncleDave added this to the v0.7.0 milestone Jun 27, 2017
@UncleDave UncleDave modified the milestones: v1.0.0, v0.7.0 Jul 7, 2017
UncleDave added a commit that referenced this issue Jul 10, 2017
…an modify each file/url or abort entirely

fixes #59
UncleDave added a commit that referenced this issue Jul 11, 2017
…an modify each file/url or abort entirely (#101)

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

Successfully merging a pull request may close this issue.

3 participants