CoreUpload in Blazor
====================

CoreUpload ships a native Blazor component, so you do not hand-write JS interop.

Run the included sample
-----------------------

1. Open a terminal in the `BlazorDemo` folder.
2. Run `dotnet run`.
3. Open the local URL shown by ASP.NET Core, then drop or pick a file.

The sample uses interactive server rendering and logs every C# event it
receives (added / progress / completed / instant-dedupe) on the page.

Adding it to your own app
-------------------------

1. Reference the CoreUpload package (the bundled one under `packages\`, or
   the published package once you are on nuget.org).

2. Register the server half in `Program.cs`:

       builder.Services.AddCoreUpload(options =>
       {
           options.TempDirectory = Path.Combine(builder.Environment.ContentRootPath, "UploaderTemp");
       });

       var app = builder.Build();
       app.UseStaticFiles();
       app.MapCoreUploadEndpoints();

3. Load the client engine once, in your host page (`Components/App.razor`),
   BEFORE `_framework/blazor.web.js`:

       <script src="_content/CoreUpload/js/coreupload.js"></script>

4. Use the component on any interactive page:

       @using CoreUpload.Components

       <CoreUploader Multiple="true"
                     AutoUpload="true"
                     Chunked="true"
                     OnTaskComplete="HandleCompleted" />

       @code {
           private Task HandleCompleted(CoreUploadFile file)
           {
               // file.FileId, file.FileName, file.FileSize, file.RelativePath, file.Deduped
               return Task.CompletedTask;
           }
       }

   The component must be rendered interactively (`@rendermode
   InteractiveServer` or `InteractiveWebAssembly`). On a statically rendered
   page there is no circuit, so no JS interop and no events.

Events
------

- OnFileAdded     (CoreUploadFile)                    - queued in the browser
- OnProgress      (CoreUploadProgress)                - bytes transferred so far
- OnTaskComplete  (CoreUploadFile)                    - one file finished, server-side
- OnQueueComplete (IReadOnlyList<CoreUploadFile>)     - the whole batch finished
- OnError         (CoreUploadError)                   - a file failed
- OnInstantUpload (CoreUploadFile)                    - matched an existing file, zero bytes sent

Notes
-----

- `Properties\launchSettings.json` sets ASPNETCORE_ENVIRONMENT=Development.
  Keep that for local runs: static web assets served out of a NuGet package
  (`_content\CoreUpload\...`) are only resolved in Development. When you
  `dotnet publish`, those assets are copied into `wwwroot` and served in any
  environment.
- Instant upload (SHA-256 dedupe) is opt-in. Set
  `options.EnableInstantUpload = true` on the server and
  `InstantUpload="true"` on the component.
- Folder drops preserve their relative path in `CoreUploadFile.RelativePath`.
