Ejemplo n.º 1
0
        public async Task <IActionResult> UploadFileToBlob(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "PC269_UploadFile")] HttpRequestMessage req,
            ILogger log)
        {
            string pc269BlobContainer = Environment.GetEnvironmentVariable("PC269_BLOB_CONTAINER");

            log.LogInformation("PC269 Upload File called");


            CommonBlob blobOps = new CommonBlob(pc269BlobContainer);

            Stream data = await req.Content.ReadAsStreamAsync();



            DateTime _date       = DateTime.Now;
            var      _dateString = _date.ToString("dd-MM-yyyy");
            string   fileName    = $"{_dateString}-{Guid.NewGuid().ToString()}.pdf";

            Uri retUri = await blobOps.uploadFileToBlob(data, fileName);

            Console.WriteLine(retUri.AbsoluteUri);

            return(new OkObjectResult(new { fileuri = retUri.AbsoluteUri }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DownloadVMDBlob(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "PC19_DownloadVMD/{fileguid}")] HttpRequestMessage req,
            ILogger log, string fileguid)
        {
            string pc19output = Environment.GetEnvironmentVariable("PC19_BLOB_CONTAINER_OUT");

            log.LogInformation("PC19 Download File called");

            CommonBlob outputBlob = new CommonBlob(pc19output);

            string outputFile = outputBlob.convertToBase64(outputBlob.downloadStreamFromBlob(fileguid).Result);

            return(new OkObjectResult(new { FileName = fileguid, FileContent = outputFile }));
        }