-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Form & Email attachments #12218
Form & Email attachments #12218
Conversation
… send email task to handle attachments
var filePaths = new List<string>(); | ||
foreach (var file in _http.HttpContext.Request.Form.Files) | ||
{ | ||
var filePath = PathExtensions.Combine(Folder, $"{workflowContext.WorkflowId}-{file.FileName}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lampersky I guess there are not many other ways to implement this on OrchardCore framework, so it should be similliar :) Not sure what you mean by same episode in dev life though :D
If you have some code working, feel free to contribute and update this PR.
Anyway thanks for feedback, I have changed it to fileStore.Combine
|
||
public override LocalizedString DisplayText => S["Save Form Attachments Task"]; | ||
|
||
public override LocalizedString Category => S["UI"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will suggest "Media" category here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changed to Media
@MikeKry is the intend to store the attachment or send it with the sent email? We already have |
// to put files in different folder, we would need either to register some private MediaFileStore, or allow to specify folder outside base path (?) | ||
var fileStore = UseMediaFileStore ? _fileStore : CreateDefaultFileStore(); | ||
var filePaths = new List<string>(); | ||
foreach (var file in _http.HttpContext.Request.Form.Files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does that work in the context that the form is not set to enctype="multipart/form-data"
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not work without that - does not break but does nothing. I put it in description of task so everyone sees that it needs multipart formdata
I think both use cases are valid. Email sending customization utilizes Attachments property that you mention. |
Can we define the destination media filename using liquid? Or at least have a default pattern that includes a custom folder and the workflow id. This could even use the request headers if the sender provides them. Users would then use the same pattern in the Email task to reference the file that was uploaded. And then create a task to delete the file (no need for a custom checkbox). In need to check what it means though to switch between media and file stores (I don't remember). |
This pull request has merge conflicts. Please resolve those before requesting a review. |
Is this something you'd like to revisit any time soon @MikeKry or should we close? I think this doesn't need to cover everything you mention in the PR description, but restrictions on file uploads (size and extension) need to be added, otherwise it wouldn't be securely usable. I'd use a per-Task config for this, with defaults coming from the Media config (and the max file size should by <= than the Media config too). |
That is good point about extension and size. I thought it is checked by MediaFileStore but now I see it is not. |
Yep, that would be necessary. Would you like to revisit this in the foreseeable future? |
It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up and remove the "stale" label. |
Closing this pull request because it has been stale for very long. If you think this is still relevant, feel free to reopen it. |
Fixes #5108, fixes #6027. Related to some other tasks.
I have created task to store attachments from OrchardCore Forms (or POST requests using multipart/form-data). It is based on code from #6027 and enhanced, still it is more like a POC, but completely working & tested. Feel free to merge or finish what is needed, I might have some time to do customizations also.
Can be used in workflows for sending mails, or just to store files without sending.
![image](https://user-images.githubusercontent.com/52829889/185352276-3dbb3f6b-4a1f-46d0-8c08-90a0570d755a.png)
Inside task, you can configure if you want files to be stored in configured media storage or custom path in App_Data/Tenant/Folder
In existing Email task there are two new checkboxes to configure this functionality. You can enable/disable sending attachments and choose if you want to remove files after sending (you may want to keep them, if you log your emails somewhere).
What I think could be added: