@Override
    public Response uploadBlob(MultipartFormDataInput multipartInput) throws IOException {
        Preconditions.checkState(securityContext.getCurrentUser() != null, "Must be logged in!");
        // Try to do image first as it is probably more likely to fail.
        MultipartUploadHolder image = MultipartHelper.getRequiredImage(multipartInput, "image", 1_048_576);
        /*
         We'll ignore the filename and generate our own to make security a bit easier.
         Preconditions.checkArgument(image.getFilename().length() > 254, "Filename too long");
         Preconditions.checkArgument(checkExtension(image.getFilename()), "Must have a recognised image extension");
        */
        Preconditions.checkArgument(checkExtension(image.getMediaType().getSubtype()), "Must have a recognised image content type (" + IMAGE_SUBTYPES_ALLOWED + ")");
        String filename = System.currentTimeMillis() + "." + image.getMediaType().getSubtype();
        // Blob is unreferenced and will be deleted if nobody attaches to it.
        BlobRef blobRef = blobStore.storeBlob(filename, image.getMediaType().toString(), image.getFileBackedOutputStream(), 0);
        // Where the blob can be resolved
        URI location = UriBuilder.fromResource(IBlobResource.class).path(blobRef.getId()).build();
        return Response
                .created(location)
                .entity(blobRef)
                .build();
    }
{@inheritDoc}

<p>Serves the blob as a stream

@param uid file's unique ID.
@return the file in response.
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/BlobResourceImpl.java