-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(Editor): add OnFileUpload parameter #6638
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
Conversation
Thanks for your PR, @j4587698. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds an OnFileUpload callback to the Editor sample by implementing a method to save uploads with timestamped names using WebsiteOptions and wiring the callback in the Razor component. Sequence diagram for Editor file upload with OnFileUpload callbacksequenceDiagram
participant User
participant EditorComponent
participant OnFileUploadMethod
participant FileSystem
User->>EditorComponent: Uploads file
EditorComponent->>OnFileUploadMethod: Calls OnFileUpload(uploadFile)
OnFileUploadMethod->>FileSystem: Save file with timestamped name
FileSystem-->>OnFileUploadMethod: Returns success/failure
OnFileUploadMethod-->>EditorComponent: Returns file URL or empty string
EditorComponent-->>User: Displays uploaded file (if successful)
Class diagram for Editor file upload callback integrationclassDiagram
class EditorUploadFile {
+string FileName
+Task<bool> SaveToFile(string fileName)
}
class WebsiteOptions {
+string WebRootPath
}
class Editors {
+Task<string> OnFileUpload(EditorUploadFile uploadFile)
}
Editors --> EditorUploadFile : uses
Editors --> WebsiteOptions : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/Editors.razor.cs:116` </location>
<code_context>
+ private async Task<string> OnFileUpload(EditorUploadFile uploadFile)
+ {
+ var url = Path.Combine("images", "uploader",
+ $"{Path.GetFileNameWithoutExtension(uploadFile.FileName)}-{DateTimeOffset.Now:yyyyMMddHHmmss}{Path.GetExtension(uploadFile.FileName)}");
+ var fileName = Path.Combine(WebsiteOption.CurrentValue.WebRootPath, url);
+ var ret = await uploadFile.SaveToFile(fileName);
+ return ret ? url : "";
</code_context>
<issue_to_address>
Path.Combine may produce platform-specific separators in URLs.
Path.Combine may introduce backslashes on Windows, leading to invalid URLs. Use a method that consistently produces forward slashes for web URLs.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
var url = Path.Combine("images", "uploader",
$"{Path.GetFileNameWithoutExtension(uploadFile.FileName)}-{DateTimeOffset.Now:yyyyMMddHHmmss}{Path.GetExtension(uploadFile.FileName)}");
=======
var url = $"images/uploader/{Path.GetFileNameWithoutExtension(uploadFile.FileName)}-{DateTimeOffset.Now:yyyyMMddHHmmss}{Path.GetExtension(uploadFile.FileName)}";
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6638 +/- ##
========================================
Coverage ? 100.00%
========================================
Files ? 739
Lines ? 31674
Branches ? 4459
========================================
Hits ? 31674
Misses ? 0
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6637
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add file upload callback support to the Editor sample demonstration, enabling uploaded files to be saved to a timestamped path under wwwroot/images/uploader.
New Features:
Enhancements: