I have read tutorials on how to upload the image to a bucket and do post processing via background function. But my requirement is to upload the image, do post processing and return the result immediately via HTTP function. Please let me know if this is the correct way to do or not as I didn't get much material online on this. Here is how I went about it:
HTTP Cloud function:
exports.uploadImage = function (req, res){
var file = req.body.file;
uploadSomewhere(file)(); < post-processing code which is working fine >
UI form:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<form id="myForm" action="<cloud_function_url>/uploadImage" method="post">
<label for="file">Choose file to upload</label>
<input type="file" id="file" name="file" multiple>
<input type="submit" value="Submit" />
</form>
<script>
$(document).ready(function() {
$('#myForm').ajaxForm(function() {
});
});
</script>
The problem is, after I deployed the function, when I upload the image from the folder where function is present, image gets uploaded. But if I upload the image from any other location, it returns me error:
Error: Error in uploading image file .... - Error: ENOENT: no such file or directory, open '....'
Please let me know what am I doing wrong or if you need more information.