Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions nuget/nuget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# FileSizeFromBase64.NET

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.
## Usage

```csharp
using FileSizeFromBase64.NET;

// File hello-world.txt => Size = 13 Bytes, Content: Hello world !
var base64String = "data:text/plain;base64,SGVsbG8gd29ybGQgIQ==";

var fileSize = FileSizeHelpers.GetFileSizeFromBase64String(base64String, true);

var fileSizeInKB = FileSizeHelpers.GetFileSizeFromBase64String(base64String, true, UnitsOfMeasurement.KiloByte);

var fileSizeInMB = FileSizeHelpers.GetFileSizeFromBase64String(base64String, true, UnitsOfMeasurement.MegaByte);
```

## Parameters

| Parameter | Type | Description | Required | Default |
|:---------------------|:-------:|:-----------:|:--------:|:-------:|
| `base64String` | string | The base64 representation of the file. | Yes | |
| `applyPaddingsRules` | bool | [Base64 Padding](https://en.wikipedia.org/wiki/Base64#Output_padding) | No | `false` |
| `unitsOfMeasurement` | Enum | `Byte`, `KiloByte`, or `MegaByte` | No | `Byte` |

## License

MIT — see [LICENSE](https://github.com/lioncoding-oss/FileSizeFromBase64.NET/blob/main/LICENSE)
4 changes: 3 additions & 1 deletion src/FileSizeFromBase64.NET/FileSizeFromBase64.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kodjo Laurent Egbakou</Authors>
<Description>Get file size from base64 string</Description>
<PackageReadmeFile>nuget.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/lioncoding-oss/FileSizeFromBase64.NET</PackageProjectUrl>
<RepositoryUrl>https://github.com/lioncoding-oss/FileSizeFromBase64.NET</RepositoryUrl>
<PackageIcon>logo.png</PackageIcon>
<Version>2.0.1</Version>
<PackageReleaseNotes>See: https://github.com/lioncoding-oss/FileSizeFromBase64.NET </PackageReleaseNotes>
<PackageTags>FileSize, Base64, Paddings, MIME-type</PackageTags>
<Copyright>Copyright 2022</Copyright>
<Copyright>Copyright 2026</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>
Expand All @@ -32,6 +33,7 @@

<ItemGroup>
<None Include="..\..\nuget\readme.txt" PackagePath="readme.txt" Pack="true" />
<None Include="..\..\nuget\nuget.md" Pack="true" PackagePath="" />
<None Include="..\..\art\logo.png" Pack="true" PackagePath="" />
</ItemGroup>

Expand Down