Skip to content

Commit 23430fd

Browse files
committed
doc: added README
1 parent 2f62529 commit 23430fd

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
3+
<div style="text-align:center"><img src="art/logo.png" width=140 /></div>
4+
5+
# FileSizeFromBase64.NET
6+
7+
A .NET Standard 2.1 project containing a single method to **get file size from base64 string**. The base64 string can contain MIME-type or not. Paddings are also supported in the decoding process, you can define whether the paddings rules should be applied or not.
8+
9+
## Installation
10+
11+
You can install the NuGet Package in any .NET Project: .NET, .NET Standard, .NET Core, .NET 5 & 6, Xamarin, Maui, ... etc.
12+
13+
FileSizeFromBase64.NET can be [found here on NuGet](https://www.nuget.org/packages/FileSizeFromBase64.NET/) and can be installed by copying and pasting the following command into your Package Manager Console within Visual Studio (Tools > NuGet Package Manager > Package Manager Console).
14+
15+
```powershell
16+
Install-Package FileSizeFromBase64.NET
17+
```
18+
19+
Alternatively, if you're using .NET Core then you can install FileSizeFromBase64.NET via the CLI with the following command:
20+
21+
```powershell
22+
dotnet add package FileSizeFromBase64.NET
23+
```
24+
25+
## Documentation
26+
27+
```csharp
28+
using FileSizeFromBase64.NET;
29+
30+
var fileSize = FileSizeHelpers.GetFileSizeFromBase64String(string base64String, bool applyPaddingsRules, UnitsOfMeasurement unitsOfMeasurement)
31+
```
32+
33+
| Parameters | Data type | Description | Default Value |
34+
| :------------------- | :-------: | :----------------------------------------------------------: | :-----------------------: |
35+
| `base64String` | string | The base64 representation of the file. | |
36+
| `applyPaddingsRules` | boolean | [Base64 - Padding](https://en.wikipedia.org/wiki/Base64#Output_padding) | `false` |
37+
| `unitsOfMeasurement` | Enum | The unit of measurement for the file size returned by the method: `UnitsOfMeasurement.Byte`, `UnitsOfMeasurement.KiloByte`, `UnitsOfMeasurement.MegaByte` | `UnitsOfMeasurement.Byte` |
38+
39+
## Usage
40+
41+
```csharp
42+
using FileSizeFromBase64.NET;
43+
44+
// File hello-world.txt => Size = 13 Bytes, Content: Hello world !
45+
var base64String = "data:text/plain;base64,SGVsbG8gd29ybGQgIQ==";
46+
47+
var fileSize = FileSizeHelpers.GetFileSizeFromBase64String(base64String, true);
48+
Console.WriteLine($"File size: {fileSize}")
49+
50+
var fileSizeInKB = FileSizeHelpers.GetFileSizeFromBase64String(base64String, true, UnitsOfMeasurement.KiloByte);
51+
52+
var fileSizeInMB = FileSizeHelpers.GetFileSizeFromBase64String(base64String, true, UnitsOfMeasurement.MegaByte);
53+
```
54+
55+
56+
57+
## Created by: Laurent Egbakou
58+
59+
- LinkedIn: [Laurent Egbakou](https://www.linkedin.com/in/laurentegbakou/)
60+
- Twitter: [@lioncoding](https://twitter.com/lioncoding)
61+
62+
## License
63+
64+
The MIT License (MIT) see [License file](https://github.com/lioncoding-oss/FileSizeFromBase64.NET/blob/main/LICENSE)
65+
66+
## Contribution
67+
68+
Feel free to create issues and PRs 😃

0 commit comments

Comments
 (0)