Last active
August 1, 2021 07:01
-
-
Save Gogetter/702aacdbcf4f56f617c7904d36504727 to your computer and use it in GitHub Desktop.
Http trigger function with Blob input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FunctionName("download") | |
@StorageAccount("<STORAGE-ACCOUNT-NAME-FROM-THIS-DEPLOYED-FUNCTION") | |
public HttpResponseMessage downloadFile( | |
@HttpTrigger( | |
name = "req", | |
methods = {HttpMethod.GET}, | |
authLevel = AuthorizationLevel.ANONYMOUS) | |
HttpRequestMessage<Optional<String>> request, | |
@BlobInput( | |
name = "filename", | |
dataType = "binary", | |
path = "java-functions-container/{filename}", | |
connection = "AzureWebJobsStorage") | |
byte[] content, | |
final ExecutionContext context) { | |
context.getLogger().info("FileDownloadHttpTrigger processed a request."); | |
if (content != null && content.length > 0) { | |
return request.createResponseBuilder(HttpStatus.OK) | |
.body(content) | |
.build(); | |
} else { | |
return request.createResponseBuilder(HttpStatus.BAD_REQUEST) | |
.body("The searched file does not exist.") | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment