Closed zoinkydoink closed 4 years ago
I am actually working on this component right now, so this message came in at a good time.
I am going to presume you meant the Nuget package, as with the code you can add your own properties. If the properties you are suggesting are something other people might find useful, I do not mind adding to the component. I am experiencing the same issue now that I am building a 'Real Sample', I found a few things I need so I added them today.
Now that you mention it, UserId, or TargetId or OwnerId, etc. is something I can see as being useful. Even ParentId and CategoryId type properties might help. This component is pretty lightweight compared to some, so adding some classification properties sounds like it would make it work for more situations.
A string property for Tag or Action is something that could also be useful.
As far as the Nuget package is concerned, another way that might work is now that Blazor supports partial classes, I moved all the code to a partial class today and I am adding some new properties and methods.
Today I added:
I think you might be able to further add your own properties like this:
namespace DataJuggler.Blazor.FileUpload { public partial class FileUpload { // Add your customizations } }
I do not know if adding additional partial classes to Nuget packages compiles or not, I have a feeling it doesn't.
You could create a class that inherits from DataJuggler.Blazor.FileUpload and add your own properties.
public partial class MyFileUpload : FileUpload { // Add your customizations }
Then just change your instances to
I am simply thinking of adding a extra property to the upload component that is int based
[Parameter]
public int CustomId { get; set; }
Then you add a corresponding property to FileUploadedInfo
that this gets sent with
Now this is very specific as being an int and its single value property. To make it even more general, you would make this some sort of array of objects so anyone can put anything they want in there and its not a single value.
Assume i have a grid of users (auto generated) User1, User2 User3
for each of the users there is a button says "upload" which has CustomId
set to that user's id and when the file upload is successful that FileUploadedInfo
will have CustomId
value sent with it so when the event is finished I can grab which user the upload was for and I can save the info to the db for that user as owning that attachment.
I hope that is clear enough, if not let me know and I can try to give a better explanation.
That makes sense. I have to eat some lunch, but by later this afternoon I should have a new version uploaded and I will add a couple of properties.
Nice thing about Blazor is everything can be a variable so it should be pretty simple.
As I implement the control, i will come up with more enhancements that will help improve the control so stay tuned for more things. I will also be testing this through out so any bugs, I shall report them
I just published a new version, 1.2.1. I am still updating the documentation on Git Hub and I need to check in for Git Hub, but this new version includes new [Parameter] properties for CustomId and Tag, in addition to other properties regarding height & width for images only. Here is an example I am working on. I actually do not know the CustomId for the use case I have now, but I added it to show you can set CustomId parameter to a variable.
The CustomId and Tag are returned if they are set on the component with UploadFileInfo if they were set.
This example contains optional parameters for an image gallery sample I am working on:
<FileUpload CustomSuccessMessage="Your file uploaded successfully." OnChange="OnFileUploaded" PartialGuidLength="10" MaxFileSize="1048576" FilterByExtension="true" AllowedExtensions=".jpg;.png;" RequiredHeight="256" RequiredWidth="256" CustomId="@SelectedArtistId" Tag="New Artist Signup Profile Image" CustomExtensionMessage="Only .jpg and .png files are allowed." AppendPartialGuid="true" CustomRequiredSizeMessage="The file must be sized to Height = 256 pixels by Width = 256 pixels." FileTooLargeMessage="The file uploaded must be 1 megabyte or smaller." UploadFolder="wwwroot\Images\Artists\"> </FileUpload>
I also added a Reset method, and in theory a Reset button is supposed to show up after an upload, if ShowResetButton is set to true, which i made the default value (this may change to have to be turned on, not sure yet).
There are also new parameter properties for ResetButtonText and ResetButtonClass, to allow you to customize this feature, or change the text to New or Change instead of Reset.
I am testing all this now, so expect some updates, but let me know if this works for your needs?
Maybe all this works as sometimes I get lucky, but it is all brand new so this is where being not so popular has its advantages. Usually I will catch a bug before anyone else notices.
I am updating Git Hub and the documentation now.
I implemented CustomId and Tag properties, so I believe this issue is closed.
If I didn't address something leave a comment or reopen this issue.
Say I have a list of users i am displaying and for each user I would like to have a "upload" button so when the button is clicked for that particular user I would like in the upload receiving method identify who that user was so i can stick that attachment for them.
Basically would like to attach "user id" as part of the upload control and then on upload then FileUploadedInfo would have this attribute I can extract and continue.
I will have lot of questions/issues as i start using this component in a application :)