diff options
Diffstat (limited to 'src/v1.erl')
-rw-r--r-- | src/v1.erl | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -157,8 +157,19 @@ add_blob(Input) -> {'EXIT', _} -> err400("add-blob: invalid base64-encoded blob", Blob); DecodedBlob -> - success(catlfish:add_chain(DecodedBlob, [], normal)) + add_blob_helper(DecodedBlob, + application:get_env(catlfish, + max_submit_size, + 0)) end; _ -> err400("add-blob: missing input: blob", Input) end. + +add_blob_helper(Blob, MaxSize) when MaxSize == 0 -> + success(catlfish:add_chain(Blob, [], normal)); +add_blob_helper(Blob, MaxSize) when erlang:size(Blob) =< MaxSize -> + add_blob_helper(Blob, 0); +add_blob_helper(Blob, MaxSize) -> + err400(io_lib:format("add-blob: blob too large (~p > ~p)", + [erlang:size(Blob), MaxSize]), Blob). |