aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/image/load.zig
blob: 51c0e261d451ca7af187bd6eefb3e1f414b3cbb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const std = @import("std");

const memora = @import("memora");
const Context = memora.Context;
const Storage = memora.Storage;

pub const access = .users;

pub fn get(ctx: *Context) ![]const u8 {
    const id = ctx.request.head.target["/api/image/load/".len..];
    var image = Storage.Image { .id = id };
    var file = try image.file(ctx.storage);
    defer file.close();

    return try file.readToEndAlloc(ctx.allocator, std.math.maxInt(usize));
}