├── .gitignore
├── BlazorFile2Azure.sln
├── Client
├── App.razor
├── BlazorFile2Azure.Client.csproj
├── BlazorFile2Azure.Client.csproj.user
├── Pages
│ ├── Counter.razor
│ ├── FetchData.razor
│ ├── Index.razor
│ ├── UploadFile.razor
│ └── ViewFiles.razor
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Shared
│ ├── MainLayout.razor
│ ├── NavMenu.razor
│ └── SurveyPrompt.razor
├── Startup.cs
├── _Imports.razor
└── wwwroot
│ ├── css
│ ├── bootstrap
│ │ ├── bootstrap.min.css
│ │ └── bootstrap.min.css.map
│ ├── open-iconic
│ │ ├── FONT-LICENSE
│ │ ├── ICON-LICENSE
│ │ ├── README.md
│ │ └── font
│ │ │ ├── css
│ │ │ └── open-iconic-bootstrap.min.css
│ │ │ └── fonts
│ │ │ ├── open-iconic.eot
│ │ │ ├── open-iconic.otf
│ │ │ ├── open-iconic.svg
│ │ │ ├── open-iconic.ttf
│ │ │ └── open-iconic.woff
│ └── site.css
│ ├── images
│ ├── Blob Storage.svg
│ └── blazorlogo.png
│ ├── index.html
│ └── inputfile.js
├── README.md
├── Server
├── BlazorFile2Azure.Server.csproj
├── BlazorFile2Azure.Server.csproj.user
├── Controllers
│ ├── FileController.cs
│ └── WeatherForecastController.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Startup.cs
└── appsettings.json
└── Shared
├── BlazorFile2Azure.Shared.csproj
└── WeatherForecast.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | .vs/
6 | bin/
7 | obj/
8 | *.user
9 |
--------------------------------------------------------------------------------
/BlazorFile2Azure.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29418.71
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorFile2Azure.Server", "Server\BlazorFile2Azure.Server.csproj", "{5A08B827-F51E-456C-BEE7-FA1B4F2BB22A}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorFile2Azure.Client", "Client\BlazorFile2Azure.Client.csproj", "{61A44FB2-AA36-4712-BC04-316D7B2A6777}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorFile2Azure.Shared", "Shared\BlazorFile2Azure.Shared.csproj", "{476BF84D-51AD-4017-A105-38EF952CDB45}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DABA663F-820F-48DF-95F2-CA07C8B92A1B}"
13 | ProjectSection(SolutionItems) = preProject
14 | README.md = README.md
15 | EndProjectSection
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {5A08B827-F51E-456C-BEE7-FA1B4F2BB22A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {5A08B827-F51E-456C-BEE7-FA1B4F2BB22A}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {5A08B827-F51E-456C-BEE7-FA1B4F2BB22A}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {5A08B827-F51E-456C-BEE7-FA1B4F2BB22A}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {61A44FB2-AA36-4712-BC04-316D7B2A6777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {61A44FB2-AA36-4712-BC04-316D7B2A6777}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {61A44FB2-AA36-4712-BC04-316D7B2A6777}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {61A44FB2-AA36-4712-BC04-316D7B2A6777}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {476BF84D-51AD-4017-A105-38EF952CDB45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {476BF84D-51AD-4017-A105-38EF952CDB45}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {476BF84D-51AD-4017-A105-38EF952CDB45}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {476BF84D-51AD-4017-A105-38EF952CDB45}.Release|Any CPU.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | GlobalSection(ExtensibilityGlobals) = postSolution
40 | SolutionGuid = {2BDCCB07-407C-44DF-899E-02A377FEEAC0}
41 | EndGlobalSection
42 | EndGlobal
43 |
--------------------------------------------------------------------------------
/Client/App.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Sorry, there's nothing at this address.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Client/BlazorFile2Azure.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | Exe
6 | 7.3
7 | 3.0
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Client/BlazorFile2Azure.Client.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | IIS Express
5 |
6 |
--------------------------------------------------------------------------------
/Client/Pages/Counter.razor:
--------------------------------------------------------------------------------
1 | @page "/counter"
2 |
3 |
Counter
4 |
5 | Current count: @currentCount
6 |
7 | Click me
8 |
9 | @code {
10 | int currentCount = 0;
11 |
12 | void IncrementCount()
13 | {
14 | currentCount++;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Client/Pages/FetchData.razor:
--------------------------------------------------------------------------------
1 | @page "/fetchdata"
2 | @using BlazorFile2Azure.Shared
3 | @inject HttpClient Http
4 |
5 | Weather forecast
6 |
7 | This component demonstrates fetching data from the server.
8 |
9 | @if (forecasts == null)
10 | {
11 | Loading...
12 | }
13 | else
14 | {
15 |
16 |
17 |
18 | Date
19 | Temp. (C)
20 | Temp. (F)
21 | Summary
22 |
23 |
24 |
25 | @foreach (var forecast in forecasts)
26 | {
27 |
28 | @forecast.Date.ToShortDateString()
29 | @forecast.TemperatureC
30 | @forecast.TemperatureF
31 | @forecast.Summary
32 |
33 | }
34 |
35 |
36 | }
37 |
38 | @code {
39 | WeatherForecast[] forecasts;
40 |
41 | protected override async Task OnInitializedAsync()
42 | {
43 | forecasts = await Http.GetJsonAsync("WeatherForecast");
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/Client/Pages/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 |
3 |
4 |
5 | Blazor WASM meet Azure Storage
6 |
7 | Upload a file to Azure Blob Storage
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Client/Pages/UploadFile.razor:
--------------------------------------------------------------------------------
1 | @page "/uploadfile"
2 | @using BlazorInputFile;
3 | @inject HttpClient Http
4 |
5 | Upload file
6 |
7 | This component demonstrates uploading a file to Azure blob storage.
8 |
9 | @if (_fileUploadCount > 0)
10 | {
11 |
12 | File upload count: @_fileUploadCount
13 |
14 | }
15 |
16 |
17 |
18 | Uploading...
19 |
20 |
21 |
22 |
23 |
24 | @_uploadError
25 |
26 |
27 |
28 |
29 |
Choose file
30 |
31 |
32 |
33 | Upload file
34 |
35 |
36 |
37 |
38 | @code {
39 |
40 | private IFileListEntry _file;
41 | private IFileListEntry[] _files;
42 | private int _fileUploadCount = 0;
43 | private string _uploadError = null;
44 | private bool _uploadingFile = false;
45 |
46 | private void HandleChangeSelected(IFileListEntry[] files)
47 | {
48 | _files = files;
49 | }
50 |
51 | private async Task FileUpload()
52 | {
53 | _uploadingFile = true;
54 |
55 | foreach (var file in _files)
56 | {
57 | using (StreamContent streamContent = new StreamContent(file.Data))
58 | {
59 | var response = await Http.PostAsync("File", streamContent);
60 | if (response.IsSuccessStatusCode)
61 | {
62 | _fileUploadCount++;
63 | }
64 | else
65 | {
66 | _uploadError = $"Error: {await response.Content.ReadAsStringAsync()}";
67 | }
68 | }
69 | }
70 | _uploadingFile = false;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Client/Pages/ViewFiles.razor:
--------------------------------------------------------------------------------
1 | @page "/viewfiles"
2 | @using System.IO
3 | @inject HttpClient Http
4 |
5 | View files
6 |
7 | This component demonstrates fetching data from Azure blob storage.
8 |
9 | @if (files == null)
10 | {
11 | Loading...
12 | }
13 | else
14 | {
15 |
16 |
17 |
18 | File path
19 | Image
20 |
21 |
22 |
23 | @foreach (var file in files)
24 | {
25 |
26 | @GetFilename(file)
27 |
28 |
29 | }
30 |
31 |
32 | }
33 |
34 | @code {
35 | List files;
36 |
37 | protected override async Task OnInitializedAsync()
38 | {
39 | files = await Http.GetJsonAsync>("File");
40 | }
41 |
42 | protected string GetFilename(string path)
43 | {
44 | return Path.GetFileName(path);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Blazor.Hosting;
2 |
3 | namespace BlazorFile2Azure.Client
4 | {
5 | public class Program
6 | {
7 | public static void Main(string[] args)
8 | {
9 | CreateHostBuilder(args).Build().Run();
10 | }
11 |
12 | public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
13 | BlazorWebAssemblyHost.CreateDefaultBuilder()
14 | .UseBlazorStartup();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Client/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:61938/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "BlazorFile2Azure.Client": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://localhost:61939/"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Client/Shared/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
6 |
7 |
8 |
11 |
12 |
13 | @Body
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Client/Shared/NavMenu.razor:
--------------------------------------------------------------------------------
1 |
7 |
8 |
37 |
38 | @code {
39 | bool collapseNavMenu = true;
40 |
41 | string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
42 |
43 | void ToggleNavMenu()
44 | {
45 | collapseNavMenu = !collapseNavMenu;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Client/Shared/SurveyPrompt.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
@Title
4 |
5 |
6 | Please take our
7 | brief survey
8 |
9 | and tell us what you think.
10 |
11 |
12 | @code {
13 | // Demonstrates how a parent component can supply parameters
14 | [Parameter] public string Title { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/Client/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Components.Builder;
2 | using Microsoft.Extensions.DependencyInjection;
3 |
4 | namespace BlazorFile2Azure.Client
5 | {
6 | public class Startup
7 | {
8 | public void ConfigureServices(IServiceCollection services)
9 | {
10 | }
11 |
12 | public void Configure(IComponentsApplicationBuilder app)
13 | {
14 | app.AddComponent("app");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Client/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using System.Net.Http
2 | @using Microsoft.AspNetCore.Components.Forms
3 | @using Microsoft.AspNetCore.Components.Routing
4 | @using Microsoft.AspNetCore.Components.Web
5 | @using Microsoft.JSInterop
6 | @using BlazorFile2Azure.Client
7 | @using BlazorFile2Azure.Client.Shared
8 |
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/FONT-LICENSE:
--------------------------------------------------------------------------------
1 | SIL OPEN FONT LICENSE Version 1.1
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | PREAMBLE
6 | The goals of the Open Font License (OFL) are to stimulate worldwide
7 | development of collaborative font projects, to support the font creation
8 | efforts of academic and linguistic communities, and to provide a free and
9 | open framework in which fonts may be shared and improved in partnership
10 | with others.
11 |
12 | The OFL allows the licensed fonts to be used, studied, modified and
13 | redistributed freely as long as they are not sold by themselves. The
14 | fonts, including any derivative works, can be bundled, embedded,
15 | redistributed and/or sold with any software provided that any reserved
16 | names are not used by derivative works. The fonts and derivatives,
17 | however, cannot be released under any other type of license. The
18 | requirement for fonts to remain under this license does not apply
19 | to any document created using the fonts or their derivatives.
20 |
21 | DEFINITIONS
22 | "Font Software" refers to the set of files released by the Copyright
23 | Holder(s) under this license and clearly marked as such. This may
24 | include source files, build scripts and documentation.
25 |
26 | "Reserved Font Name" refers to any names specified as such after the
27 | copyright statement(s).
28 |
29 | "Original Version" refers to the collection of Font Software components as
30 | distributed by the Copyright Holder(s).
31 |
32 | "Modified Version" refers to any derivative made by adding to, deleting,
33 | or substituting -- in part or in whole -- any of the components of the
34 | Original Version, by changing formats or by porting the Font Software to a
35 | new environment.
36 |
37 | "Author" refers to any designer, engineer, programmer, technical
38 | writer or other person who contributed to the Font Software.
39 |
40 | PERMISSION & CONDITIONS
41 | Permission is hereby granted, free of charge, to any person obtaining
42 | a copy of the Font Software, to use, study, copy, merge, embed, modify,
43 | redistribute, and sell modified and unmodified copies of the Font
44 | Software, subject to the following conditions:
45 |
46 | 1) Neither the Font Software nor any of its individual components,
47 | in Original or Modified Versions, may be sold by itself.
48 |
49 | 2) Original or Modified Versions of the Font Software may be bundled,
50 | redistributed and/or sold with any software, provided that each copy
51 | contains the above copyright notice and this license. These can be
52 | included either as stand-alone text files, human-readable headers or
53 | in the appropriate machine-readable metadata fields within text or
54 | binary files as long as those fields can be easily viewed by the user.
55 |
56 | 3) No Modified Version of the Font Software may use the Reserved Font
57 | Name(s) unless explicit written permission is granted by the corresponding
58 | Copyright Holder. This restriction only applies to the primary font name as
59 | presented to the users.
60 |
61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
62 | Software shall not be used to promote, endorse or advertise any
63 | Modified Version, except to acknowledge the contribution(s) of the
64 | Copyright Holder(s) and the Author(s) or with their explicit written
65 | permission.
66 |
67 | 5) The Font Software, modified or unmodified, in part or in whole,
68 | must be distributed entirely under this license, and must not be
69 | distributed under any other license. The requirement for fonts to
70 | remain under this license does not apply to any document created
71 | using the Font Software.
72 |
73 | TERMINATION
74 | This license becomes null and void if any of the above conditions are
75 | not met.
76 |
77 | DISCLAIMER
78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
86 | OTHER DEALINGS IN THE FONT SOFTWARE.
87 |
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/README.md:
--------------------------------------------------------------------------------
1 | [Open Iconic v1.1.1](http://useiconic.com/open)
2 | ===========
3 |
4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons)
5 |
6 |
7 |
8 | ## What's in Open Iconic?
9 |
10 | * 223 icons designed to be legible down to 8 pixels
11 | * Super-light SVG files - 61.8 for the entire set
12 | * SVG sprite—the modern replacement for icon fonts
13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats
14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats
15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px.
16 |
17 |
18 | ## Getting Started
19 |
20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections.
21 |
22 | ### General Usage
23 |
24 | #### Using Open Iconic's SVGs
25 |
26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute).
27 |
28 | ```
29 |
30 | ```
31 |
32 | #### Using Open Iconic's SVG Sprite
33 |
34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack.
35 |
36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.*
37 |
38 | ```
39 |
40 |
41 |
42 | ```
43 |
44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions.
45 |
46 | ```
47 | .icon {
48 | width: 16px;
49 | height: 16px;
50 | }
51 | ```
52 |
53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag.
54 |
55 | ```
56 | .icon-account-login {
57 | fill: #f00;
58 | }
59 | ```
60 |
61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/).
62 |
63 | #### Using Open Iconic's Icon Font...
64 |
65 |
66 | ##### …with Bootstrap
67 |
68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}`
69 |
70 |
71 | ```
72 |
73 | ```
74 |
75 |
76 | ```
77 |
78 | ```
79 |
80 | ##### …with Foundation
81 |
82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}`
83 |
84 | ```
85 |
86 | ```
87 |
88 |
89 | ```
90 |
91 | ```
92 |
93 | ##### …on its own
94 |
95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}`
96 |
97 | ```
98 |
99 | ```
100 |
101 | ```
102 |
103 | ```
104 |
105 |
106 | ## License
107 |
108 | ### Icons
109 |
110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT).
111 |
112 | ### Fonts
113 |
114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web).
115 |
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css:
--------------------------------------------------------------------------------
1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'}
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daltskin/BlazorFile2Azure/20ecec2fd78827d332e8df0b0dac66f4e96c0d02/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daltskin/BlazorFile2Azure/20ecec2fd78827d332e8df0b0dac66f4e96c0d02/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014
9 | By P.J. Onori
10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net)
11 |
12 |
13 |
14 |
27 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
45 |
47 |
49 |
51 |
53 |
55 |
57 |
59 |
61 |
63 |
65 |
67 |
69 |
71 |
74 |
76 |
79 |
81 |
84 |
86 |
88 |
91 |
93 |
95 |
98 |
100 |
102 |
104 |
106 |
109 |
112 |
115 |
117 |
121 |
123 |
125 |
127 |
130 |
132 |
134 |
136 |
138 |
141 |
143 |
145 |
147 |
149 |
151 |
153 |
155 |
157 |
159 |
162 |
165 |
167 |
169 |
172 |
174 |
177 |
179 |
181 |
183 |
185 |
189 |
191 |
194 |
196 |
198 |
200 |
202 |
205 |
207 |
209 |
211 |
213 |
215 |
218 |
220 |
222 |
224 |
226 |
228 |
230 |
232 |
234 |
236 |
238 |
241 |
243 |
245 |
247 |
249 |
251 |
253 |
256 |
259 |
261 |
263 |
265 |
267 |
269 |
272 |
274 |
276 |
280 |
282 |
285 |
287 |
289 |
292 |
295 |
298 |
300 |
302 |
304 |
306 |
309 |
312 |
314 |
316 |
318 |
320 |
322 |
324 |
326 |
330 |
334 |
338 |
340 |
343 |
345 |
347 |
349 |
351 |
353 |
355 |
358 |
360 |
363 |
365 |
367 |
369 |
371 |
373 |
375 |
377 |
379 |
381 |
383 |
386 |
388 |
390 |
392 |
394 |
396 |
399 |
401 |
404 |
406 |
408 |
410 |
412 |
414 |
416 |
419 |
421 |
423 |
425 |
428 |
431 |
435 |
438 |
440 |
442 |
444 |
446 |
448 |
451 |
453 |
455 |
457 |
460 |
462 |
464 |
466 |
468 |
471 |
473 |
477 |
479 |
481 |
483 |
486 |
488 |
490 |
492 |
494 |
496 |
499 |
501 |
504 |
506 |
509 |
512 |
515 |
517 |
520 |
522 |
524 |
526 |
529 |
532 |
534 |
536 |
539 |
542 |
543 |
544 |
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daltskin/BlazorFile2Azure/20ecec2fd78827d332e8df0b0dac66f4e96c0d02/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf
--------------------------------------------------------------------------------
/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daltskin/BlazorFile2Azure/20ecec2fd78827d332e8df0b0dac66f4e96c0d02/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff
--------------------------------------------------------------------------------
/Client/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
2 |
3 | html, body {
4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
5 | }
6 |
7 | app {
8 | position: relative;
9 | display: flex;
10 | flex-direction: column;
11 | }
12 |
13 | .top-row {
14 | height: 3.5rem;
15 | display: flex;
16 | align-items: center;
17 | }
18 |
19 | .main {
20 | flex: 1;
21 | }
22 |
23 | .main .top-row {
24 | background-color: #e6e6e6;
25 | border-bottom: 1px solid #d6d5d5;
26 | }
27 |
28 | .sidebar {
29 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
30 | }
31 |
32 | .sidebar .top-row {
33 | background-color: rgba(0,0,0,0.4);
34 | }
35 |
36 | .sidebar .navbar-brand {
37 | font-size: 1.1rem;
38 | }
39 |
40 | .sidebar .oi {
41 | width: 2rem;
42 | font-size: 1.1rem;
43 | vertical-align: text-top;
44 | top: -2px;
45 | }
46 |
47 | .nav-item {
48 | font-size: 0.9rem;
49 | padding-bottom: 0.5rem;
50 | }
51 |
52 | .nav-item:first-of-type {
53 | padding-top: 1rem;
54 | }
55 |
56 | .nav-item:last-of-type {
57 | padding-bottom: 1rem;
58 | }
59 |
60 | .nav-item a {
61 | color: #d7d7d7;
62 | border-radius: 4px;
63 | height: 3rem;
64 | display: flex;
65 | align-items: center;
66 | line-height: 3rem;
67 | }
68 |
69 | .nav-item a.active {
70 | background-color: rgba(255,255,255,0.25);
71 | color: white;
72 | }
73 |
74 | .nav-item a:hover {
75 | background-color: rgba(255,255,255,0.1);
76 | color: white;
77 | }
78 |
79 | .content {
80 | padding-top: 1.1rem;
81 | }
82 |
83 | .navbar-toggler {
84 | background-color: rgba(255, 255, 255, 0.1);
85 | }
86 |
87 | .valid.modified:not([type=checkbox]) {
88 | outline: 1px solid #26b050;
89 | }
90 |
91 | .invalid {
92 | outline: 1px solid red;
93 | }
94 |
95 | .validation-message {
96 | color: red;
97 | }
98 |
99 | @media (max-width: 767.98px) {
100 | .main .top-row {
101 | display: none;
102 | }
103 | }
104 |
105 | @media (min-width: 768px) {
106 | app {
107 | flex-direction: row;
108 | }
109 |
110 | .sidebar {
111 | width: 250px;
112 | height: 100vh;
113 | position: sticky;
114 | top: 0;
115 | }
116 |
117 | .main .top-row {
118 | position: sticky;
119 | top: 0;
120 | }
121 |
122 | .main > div {
123 | padding-left: 2rem !important;
124 | padding-right: 1.5rem !important;
125 | }
126 |
127 | .navbar-toggler {
128 | display: none;
129 | }
130 |
131 | .sidebar .collapse {
132 | /* Never collapse the sidebar for wide screens */
133 | display: block;
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/Client/wwwroot/images/Blob Storage.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Client/wwwroot/images/blazorlogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daltskin/BlazorFile2Azure/20ecec2fd78827d332e8df0b0dac66f4e96c0d02/Client/wwwroot/images/blazorlogo.png
--------------------------------------------------------------------------------
/Client/wwwroot/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | BlazorFile2Azure
7 |
8 |
9 |
10 |
11 |
12 | Loading...
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Client/wwwroot/inputfile.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | window.BlazorInputFile = {
3 | init: function init(elem, componentInstance) {
4 | var nextFileId = 0;
5 |
6 | elem.addEventListener('change', function handleInputFileChange(event) {
7 | // Reduce to purely serializable data, plus build an index by ID
8 | elem._blazorFilesById = {};
9 | var fileList = Array.prototype.map.call(elem.files, function (file) {
10 | var result = {
11 | id: ++nextFileId,
12 | lastModified: new Date(file.lastModified).toISOString(),
13 | name: file.name,
14 | size: file.size,
15 | type: file.type
16 | };
17 | elem._blazorFilesById[result.id] = result;
18 |
19 | // Attach the blob data itself as a non-enumerable property so it doesn't appear in the JSON
20 | Object.defineProperty(result, 'blob', { value: file });
21 |
22 | return result;
23 | });
24 |
25 | componentInstance.invokeMethodAsync('NotifyChange', fileList).then(null, function (err) {
26 | throw new Error(err);
27 | });
28 | });
29 | },
30 |
31 | readFileData: function readFileData(elem, fileId, startOffset, count) {
32 | var readPromise = getArrayBufferFromFileAsync(elem, fileId);
33 |
34 | return readPromise.then(function (arrayBuffer) {
35 | var uint8Array = new Uint8Array(arrayBuffer, startOffset, count);
36 | var base64 = uint8ToBase64(uint8Array);
37 | return base64;
38 | });
39 | },
40 |
41 | ensureArrayBufferReadyForSharedMemoryInterop: function ensureArrayBufferReadyForSharedMemoryInterop(elem, fileId) {
42 | return getArrayBufferFromFileAsync(elem, fileId).then(function (arrayBuffer) {
43 | getFileById(elem, fileId).arrayBuffer = arrayBuffer;
44 | });
45 | },
46 |
47 | readFileDataSharedMemory: function readFileDataSharedMemory(readRequest) {
48 | // This uses various unsupported internal APIs. Beware that if you also use them,
49 | // your code could become broken by any update.
50 | var inputFileElementReferenceId = Blazor.platform.readStringField(readRequest, 0);
51 | var inputFileElement = document.querySelector('[_bl_' + inputFileElementReferenceId + ']');
52 | var fileId = Blazor.platform.readInt32Field(readRequest, 4);
53 | var sourceOffset = Blazor.platform.readUint64Field(readRequest, 8);
54 | var destination = Blazor.platform.readInt32Field(readRequest, 16);
55 | var destinationOffset = Blazor.platform.readInt32Field(readRequest, 20);
56 | var maxBytes = Blazor.platform.readInt32Field(readRequest, 24);
57 |
58 | var sourceArrayBuffer = getFileById(inputFileElement, fileId).arrayBuffer;
59 | var bytesToRead = Math.min(maxBytes, sourceArrayBuffer.byteLength - sourceOffset);
60 | var sourceUint8Array = new Uint8Array(sourceArrayBuffer, sourceOffset, bytesToRead);
61 |
62 | var destinationUint8Array = Blazor.platform.toUint8Array(destination);
63 | destinationUint8Array.set(sourceUint8Array, destinationOffset);
64 |
65 | return bytesToRead;
66 | }
67 | };
68 |
69 | function getFileById(elem, fileId) {
70 | var file = elem._blazorFilesById[fileId];
71 | if (!file) {
72 | throw new Error('There is no file with ID ' + fileId + '. The file list may have changed');
73 | }
74 |
75 | return file;
76 | }
77 |
78 | function getArrayBufferFromFileAsync(elem, fileId) {
79 | var file = getFileById(elem, fileId);
80 |
81 | // On the first read, convert the FileReader into a Promise
82 | if (!file.readPromise) {
83 | file.readPromise = new Promise(function (resolve, reject) {
84 | var reader = new FileReader();
85 | reader.onload = function () { resolve(reader.result); };
86 | reader.onerror = function (err) { reject(err); };
87 | reader.readAsArrayBuffer(file.blob);
88 | });
89 | }
90 |
91 | return file.readPromise;
92 | }
93 |
94 | var uint8ToBase64 = (function () {
95 | // Code from https://github.com/beatgammit/base64-js/
96 | // License: MIT
97 | var lookup = [];
98 |
99 | var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
100 | for (var i = 0, len = code.length; i < len; ++i) {
101 | lookup[i] = code[i];
102 | }
103 |
104 | function tripletToBase64(num) {
105 | return lookup[num >> 18 & 0x3F] +
106 | lookup[num >> 12 & 0x3F] +
107 | lookup[num >> 6 & 0x3F] +
108 | lookup[num & 0x3F];
109 | }
110 |
111 | function encodeChunk(uint8, start, end) {
112 | var tmp;
113 | var output = [];
114 | for (var i = start; i < end; i += 3) {
115 | tmp =
116 | ((uint8[i] << 16) & 0xFF0000) +
117 | ((uint8[i + 1] << 8) & 0xFF00) +
118 | (uint8[i + 2] & 0xFF);
119 | output.push(tripletToBase64(tmp));
120 | }
121 | return output.join('');
122 | }
123 |
124 | return function fromByteArray(uint8) {
125 | var tmp;
126 | var len = uint8.length;
127 | var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
128 | var parts = [];
129 | var maxChunkLength = 16383; // must be multiple of 3
130 |
131 | // go through the array every three bytes, we'll deal with trailing stuff later
132 | for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
133 | parts.push(encodeChunk(
134 | uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
135 | ));
136 | }
137 |
138 | // pad the end with zeros, but make sure to not forget the extra bytes
139 | if (extraBytes === 1) {
140 | tmp = uint8[len - 1];
141 | parts.push(
142 | lookup[tmp >> 2] +
143 | lookup[(tmp << 4) & 0x3F] +
144 | '=='
145 | );
146 | } else if (extraBytes === 2) {
147 | tmp = (uint8[len - 2] << 8) + uint8[len - 1];
148 | parts.push(
149 | lookup[tmp >> 10] +
150 | lookup[(tmp >> 4) & 0x3F] +
151 | lookup[(tmp << 2) & 0x3F] +
152 | '='
153 | );
154 | }
155 |
156 | return parts.join('');
157 | };
158 | })();
159 | })();
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BlazorFile2Azure
2 |
3 | ### Blazor WebAssembly sample to upload a file to Azure Blob Storage via an API
4 |
5 | This application uses [Steve Sanderson's](https://twitter.com/stevensanderson) [BlazorInputFile](https://github.com/SteveSandersonMS/BlazorInputFile) to upload files and save them to Azure Blob Storage.
6 |
7 | #### BlazorFile2Azure.Client
8 |
9 | This Blazor WASM application that utilises the BlazorInputFile, checking that file(s) have been selected and then calls posts them to the server-side API.
10 |
11 | #### BlazorFile2Azure.Server
12 |
13 | The API controller that hosts the Blazor application and server-side API.
14 |
15 | ### Instructions
16 |
17 | Add your Azure Blob Storage `connection string` and `container name` within the appSettings.json file:
18 |
19 | | Key | Description |
20 | | ----- | ----- |
21 | | blobConnectionString | Azure Blob storage Connection String |
22 | | blobStorageContainer | The container name within your storage account |
23 |
24 | ### How it works
25 |
26 | Blazor client simply iterates the selected files within FileListEntry array and posts each stream to the server side (API controller). Which in turn uses the Azure Blob Storage SDK to upload the stream to a specified blob storage container.
27 |
28 | Blazor components support [attribute splatting and arbitary parameters](https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0#attribute-splatting-and-arbitrary-parameters) - Steve's BlazorInputFile control uses this:
29 |
30 | ```
31 |
32 |
33 | @code {
34 | [Parameter(CaptureUnmatchedValues = false)] public Dictionary UnmatchedParameters { get; set; }
35 | ```
36 |
37 | Meaning, that we can add the additional file input attributes such as capture mode and file type support :)
38 | ```
39 |
40 | ```
41 |
42 | ### Known issue
43 |
44 | * Clearing value of input element: https://github.com/SteveSandersonMS/BlazorInputFile/issues/2
45 |
--------------------------------------------------------------------------------
/Server/BlazorFile2Azure.Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.0
5 | 8.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Server/BlazorFile2Azure.Server.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | IIS Express
5 | MvcControllerEmptyScaffolder
6 | root/Controller
7 | 600
8 | True
9 | False
10 | True
11 |
12 | False
13 |
14 |
--------------------------------------------------------------------------------
/Server/Controllers/FileController.cs:
--------------------------------------------------------------------------------
1 | using Azure.Storage.Blobs;
2 | using Microsoft.AspNetCore.Mvc;
3 | using Microsoft.Extensions.Configuration;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlazorFile2Azure.Server.Controllers
9 | {
10 | [ApiController]
11 | [Route("[controller]")]
12 | public class FileController : Controller
13 | {
14 | IConfiguration _configuration;
15 |
16 | public FileController(IConfiguration configuration)
17 | {
18 | _configuration = configuration;
19 | }
20 |
21 | [HttpGet]
22 | public async Task> Get()
23 | {
24 | List results = new List();
25 |
26 | var container = GetContainer();
27 | string prefix = container.Uri.ToString();
28 |
29 | await foreach (var blob in container.GetBlobsAsync())
30 | {
31 | results.Add($"{prefix}/{blob.Name}");
32 | }
33 |
34 | return results;
35 | }
36 |
37 | [HttpPost]
38 | public async Task Post()
39 | {
40 | try
41 | {
42 | var container = GetContainer();
43 | string fileName = $"{Guid.NewGuid().ToString()}.jpg";
44 | var blob = container.GetBlobClient(fileName);
45 | await blob.UploadAsync(Request.Body);
46 | }
47 | catch (Exception)
48 | {
49 | return new BadRequestObjectResult("Error saving file");
50 | }
51 |
52 | return new OkObjectResult("ok");
53 | }
54 |
55 | #region helper
56 | private BlobContainerClient GetContainer()
57 | {
58 | string blobConnectionString = _configuration["blobConnectionString"];
59 | string blobContainerName = _configuration["blobStorageContainer"];
60 |
61 | var container = new BlobContainerClient(blobConnectionString, blobContainerName);
62 | container.CreateIfNotExists();
63 |
64 | return container;
65 | }
66 | #endregion
67 | }
68 | }
--------------------------------------------------------------------------------
/Server/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using BlazorFile2Azure.Shared;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.Extensions.Logging;
8 |
9 | namespace BlazorFile2Azure.Server.Controllers
10 | {
11 | [ApiController]
12 | [Route("[controller]")]
13 | public class WeatherForecastController : ControllerBase
14 | {
15 | private static readonly string[] Summaries = new[]
16 | {
17 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
18 | };
19 |
20 | private readonly ILogger logger;
21 |
22 | public WeatherForecastController(ILogger logger)
23 | {
24 | this.logger = logger;
25 | }
26 |
27 | [HttpGet]
28 | public IEnumerable Get()
29 | {
30 | var rng = new Random();
31 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
32 | {
33 | Date = DateTime.Now.AddDays(index),
34 | TemperatureC = rng.Next(-20, 55),
35 | Summary = Summaries[rng.Next(Summaries.Length)]
36 | })
37 | .ToArray();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.Configuration;
4 |
5 | namespace BlazorFile2Azure.Server
6 | {
7 | public class Program
8 | {
9 | public static void Main(string[] args)
10 | {
11 | BuildWebHost(args).Run();
12 | }
13 |
14 | public static IWebHost BuildWebHost(string[] args) =>
15 | WebHost.CreateDefaultBuilder(args)
16 | .UseConfiguration(new ConfigurationBuilder()
17 | .AddCommandLine(args)
18 | .Build())
19 | .UseStartup()
20 | .Build();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:61936/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "BlazorFile2Azure.Server": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://localhost:61937/"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Server/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.ResponseCompression;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.Hosting;
6 | using Newtonsoft.Json.Serialization;
7 | using System.Linq;
8 |
9 | namespace BlazorFile2Azure.Server
10 | {
11 | public class Startup
12 | {
13 | // This method gets called by the runtime. Use this method to add services to the container.
14 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
15 | public void ConfigureServices(IServiceCollection services)
16 | {
17 | services.AddMvc(); //.AddNewtonsoftJson();
18 | services.AddResponseCompression(opts =>
19 | {
20 | opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
21 | new[] { "application/octet-stream" });
22 | });
23 | }
24 |
25 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
26 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
27 | {
28 | app.UseResponseCompression();
29 |
30 | if (env.IsDevelopment())
31 | {
32 | app.UseDeveloperExceptionPage();
33 | app.UseBlazorDebugging();
34 | }
35 |
36 | app.UseStaticFiles();
37 | app.UseClientSideBlazorFiles();
38 |
39 | app.UseRouting();
40 |
41 | app.UseEndpoints(endpoints =>
42 | {
43 | endpoints.MapDefaultControllerRoute();
44 | endpoints.MapFallbackToClientSideBlazor("index.html");
45 | });
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Server/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "blobConnectionString": "",
3 | "blobStorageContainer": ""
4 | }
5 |
--------------------------------------------------------------------------------
/Shared/BlazorFile2Azure.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 7.3
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Shared/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BlazorFile2Azure.Shared
6 | {
7 | public class WeatherForecast
8 | {
9 | public DateTime Date { get; set; }
10 |
11 | public int TemperatureC { get; set; }
12 |
13 | public string Summary { get; set; }
14 |
15 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------