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

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));
}