Suggestion: RadzenUpload could have a before-upload event

Hi,

RadzenUpload is all right, but it could be better.

For instance, a "before the upload is started" event that will allow us to update the header of the upload request. That's particularly useful when authenticated uploads have to be made and the header has to be set for a bunch of upload controls that are being rendered using a list. I would rather set the header before the upload is about to be started rather than pre-rendering it by using the <RadzenUploadHeader Name="Authorization" Value="@authorizationValue" />.

Does it qualify for a feature request? :slight_smile:

Thanks

Hi @Lucian_Naie,

Thanks, I guess?

Do you really need to set the headers every time before upload? Setting a header via <RadzenUploadHeader /> shouldn't be considered "prerendering". It is configuration of the component.

That's probably two feature requests - first event firing before upload and second the ability to set headers during that event (which would require a roundtrip to the server). Still feel free to open a new issue in our github repository. We would also accept a pull request.

Thanks for the clarifications.

That's probably two feature requests - first event firing before upload and second the ability to set headers during that event (which would require a roundtrip to the server). Still feel free to open a new issue in our github repository. We would also accept a pull request.

I don't understand why would it require a roundtrip to the server? The upload request hasn't been sent, and probably it's been created. So I'm thinking that getting a reference to it in the event and adding a header should be relatively easy.
I haven't seen the code yet, but I'll check what's there.

Uploads are done on the client-side via JavaScript. In a Blazor server application we would need an additional server roundtrip (to get custom headers).

Ok, clear.
I started to look into the code, particularly at the XMLHttpRequest to see if and how that could be achieved.
Do you have a document about how to start to contribute to the project?
I cloned the git repo and while trying to build and run the demo project, I get this unusual error:

1>Unhandled exception. System.IO.IOException: The process cannot access the file 'C:\Projects\github\radzen-blazor\Radzen.Blazor\themes\default-base.css' because it is being used by another process.
1>   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
1>   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
1>   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
1>   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
1>   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
1>   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
1>   at System.IO.File.ReadAllText(String path, Encoding encoding)
1>   at WebCompiler.Compile.Compiler.ReplaceIfNewer(String output_file, String new_content) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Compile/Compiler.cs:line 19
1>   at WebCompiler.Compile.SassCompiler.Compile(List`1 file_sequence) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Compile/SassCompiler.cs:line 86
1>   at WebCompiler.Compile.CompilationStep.With(Compiler compiler) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Compile/CompilationStep.cs:line 19
1>   at WebCompiler.Compile.Compilers.TryCompile(String file) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Compile/Compilers.cs:line 36
1>   at WebCompiler.Program.Main(String[] args) in /home/runner/work/WebCompiler/WebCompiler/WebCompiler/Program.cs:line 213
1>C:\Projects\github\radzen-blazor\Radzen.Blazor\Radzen.Blazor.csproj(68,5): error MSB3073: The command "dotnet tool run webcompiler -r themes -o wwwroot/css -z disable -m disable -p disable" exited with code -532462766.
1>Done building project "Radzen.Blazor.csproj" -- FAILED.