Add avatars
30
NostrServices/Controllers/AvatarController.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace NostrServices.Controllers;
|
||||||
|
|
||||||
|
[Route("/api/v1/avatar")]
|
||||||
|
public class AvatarController : Controller
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Robohash avatar endpoints
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Available sets: `cyberpunks`
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="set"></param>
|
||||||
|
/// <param name="value">Any value, can contain a file extension, response is only image/webp</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{set}/{value}")]
|
||||||
|
[ResponseCache(Location = ResponseCacheLocation.Any, Duration = 86400)]
|
||||||
|
public IActionResult GetAvatar([FromRoute] string set, [FromRoute] string value)
|
||||||
|
{
|
||||||
|
var hash = System.Security.Cryptography.SHA256.HashData(
|
||||||
|
Encoding.UTF8.GetBytes(Path.GetFileNameWithoutExtension(value)));
|
||||||
|
var hashInt = BitConverter.ToInt32(hash);
|
||||||
|
var dir = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", set);
|
||||||
|
var fileList = Directory.EnumerateFiles(dir, "*.webp").ToList();
|
||||||
|
var pickImg = fileList[Math.Abs(hashInt % fileList.Count)];
|
||||||
|
return PhysicalFile(pickImg, "image/webp");
|
||||||
|
}
|
||||||
|
}
|
BIN
NostrServices/wwwroot/cyberpunks/robohash_00001_.webp
Normal file
After Width: | Height: | Size: 199 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00002_.webp
Normal file
After Width: | Height: | Size: 203 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00003_.webp
Normal file
After Width: | Height: | Size: 203 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00004_.webp
Normal file
After Width: | Height: | Size: 265 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00005_.webp
Normal file
After Width: | Height: | Size: 194 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00006_.webp
Normal file
After Width: | Height: | Size: 195 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00007_.webp
Normal file
After Width: | Height: | Size: 266 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00008_.webp
Normal file
After Width: | Height: | Size: 227 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00009_.webp
Normal file
After Width: | Height: | Size: 282 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00010_.webp
Normal file
After Width: | Height: | Size: 242 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00011_.webp
Normal file
After Width: | Height: | Size: 234 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00012_.webp
Normal file
After Width: | Height: | Size: 284 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00013_.webp
Normal file
After Width: | Height: | Size: 210 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00014_.webp
Normal file
After Width: | Height: | Size: 204 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00015_.webp
Normal file
After Width: | Height: | Size: 160 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00016_.webp
Normal file
After Width: | Height: | Size: 239 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00017_.webp
Normal file
After Width: | Height: | Size: 254 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00018_.webp
Normal file
After Width: | Height: | Size: 251 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00019_.webp
Normal file
After Width: | Height: | Size: 249 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00020_.webp
Normal file
After Width: | Height: | Size: 289 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00021_.webp
Normal file
After Width: | Height: | Size: 198 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00022_.webp
Normal file
After Width: | Height: | Size: 210 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00023_.webp
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00024_.webp
Normal file
After Width: | Height: | Size: 182 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00025_.webp
Normal file
After Width: | Height: | Size: 154 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00026_.webp
Normal file
After Width: | Height: | Size: 176 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00027_.webp
Normal file
After Width: | Height: | Size: 208 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00028_.webp
Normal file
After Width: | Height: | Size: 176 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00029_.webp
Normal file
After Width: | Height: | Size: 164 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00030_.webp
Normal file
After Width: | Height: | Size: 144 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00031_.webp
Normal file
After Width: | Height: | Size: 204 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00032_.webp
Normal file
After Width: | Height: | Size: 195 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00033_.webp
Normal file
After Width: | Height: | Size: 217 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00034_.webp
Normal file
After Width: | Height: | Size: 185 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00035_.webp
Normal file
After Width: | Height: | Size: 298 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00036_.webp
Normal file
After Width: | Height: | Size: 366 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00037_.webp
Normal file
After Width: | Height: | Size: 330 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00038_.webp
Normal file
After Width: | Height: | Size: 355 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00039_.webp
Normal file
After Width: | Height: | Size: 301 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00040_.webp
Normal file
After Width: | Height: | Size: 317 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00041_.webp
Normal file
After Width: | Height: | Size: 349 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00042_.webp
Normal file
After Width: | Height: | Size: 341 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00043_.webp
Normal file
After Width: | Height: | Size: 281 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00044_.webp
Normal file
After Width: | Height: | Size: 304 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00045_.webp
Normal file
After Width: | Height: | Size: 428 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00046_.webp
Normal file
After Width: | Height: | Size: 204 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00047_.webp
Normal file
After Width: | Height: | Size: 211 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00048_.webp
Normal file
After Width: | Height: | Size: 212 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00049_.webp
Normal file
After Width: | Height: | Size: 238 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00050_.webp
Normal file
After Width: | Height: | Size: 221 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00051_.webp
Normal file
After Width: | Height: | Size: 248 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00052_.webp
Normal file
After Width: | Height: | Size: 243 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00053_.webp
Normal file
After Width: | Height: | Size: 204 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00054_.webp
Normal file
After Width: | Height: | Size: 251 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00055_.webp
Normal file
After Width: | Height: | Size: 225 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00056_.webp
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00057_.webp
Normal file
After Width: | Height: | Size: 232 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00058_.webp
Normal file
After Width: | Height: | Size: 268 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00059_.webp
Normal file
After Width: | Height: | Size: 245 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00060_.webp
Normal file
After Width: | Height: | Size: 237 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00061_.webp
Normal file
After Width: | Height: | Size: 219 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00062_.webp
Normal file
After Width: | Height: | Size: 227 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00063_.webp
Normal file
After Width: | Height: | Size: 201 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00064_.webp
Normal file
After Width: | Height: | Size: 234 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00065_.webp
Normal file
After Width: | Height: | Size: 282 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00066_.webp
Normal file
After Width: | Height: | Size: 172 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00067_.webp
Normal file
After Width: | Height: | Size: 207 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00068_.webp
Normal file
After Width: | Height: | Size: 154 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00069_.webp
Normal file
After Width: | Height: | Size: 188 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00070_.webp
Normal file
After Width: | Height: | Size: 162 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00071_.webp
Normal file
After Width: | Height: | Size: 235 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00072_.webp
Normal file
After Width: | Height: | Size: 238 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00073_.webp
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00074_.webp
Normal file
After Width: | Height: | Size: 299 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00075_.webp
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00076_.webp
Normal file
After Width: | Height: | Size: 261 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00077_.webp
Normal file
After Width: | Height: | Size: 242 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00078_.webp
Normal file
After Width: | Height: | Size: 296 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00079_.webp
Normal file
After Width: | Height: | Size: 251 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00080_.webp
Normal file
After Width: | Height: | Size: 290 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00081_.webp
Normal file
After Width: | Height: | Size: 180 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00082_.webp
Normal file
After Width: | Height: | Size: 272 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00083_.webp
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00084_.webp
Normal file
After Width: | Height: | Size: 315 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00085_.webp
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00086_.webp
Normal file
After Width: | Height: | Size: 209 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00087_.webp
Normal file
After Width: | Height: | Size: 187 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00088_.webp
Normal file
After Width: | Height: | Size: 149 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00089_.webp
Normal file
After Width: | Height: | Size: 180 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00090_.webp
Normal file
After Width: | Height: | Size: 242 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00091_.webp
Normal file
After Width: | Height: | Size: 178 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00092_.webp
Normal file
After Width: | Height: | Size: 208 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00093_.webp
Normal file
After Width: | Height: | Size: 219 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00094_.webp
Normal file
After Width: | Height: | Size: 193 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00095_.webp
Normal file
After Width: | Height: | Size: 225 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00096_.webp
Normal file
After Width: | Height: | Size: 206 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00097_.webp
Normal file
After Width: | Height: | Size: 263 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00098_.webp
Normal file
After Width: | Height: | Size: 220 KiB |
BIN
NostrServices/wwwroot/cyberpunks/robohash_00099_.webp
Normal file
After Width: | Height: | Size: 182 KiB |