Exemplo n.º 1
0
        public async Task <MessageResponse> DownloadFileHandler(Message message, object context)
        {
            try
            {
                string targetPath     = message.Properties["path"];
                string targetFilename = message.Properties["filename"];
                bool   append         = message.Properties.ContainsKey("append") ? Convert.ToBoolean(message.Properties["append"]) : false;
                string containerName  = message.Properties.ContainsKey("blobPath") ? message.Properties["blobPath"] : null;
                string filename       = message.Properties.ContainsKey("blobFilename") ? message.Properties["blobFilename"] : null;
                string sasUri         = message.Properties.ContainsKey("sasUri") ? message.Properties["sasUri"] : null;


                if (sasUri != null)
                {
                    await local.DownloadFile(targetPath, targetFilename, sasUri, append);
                }
                else
                {
                    await local.DownloadFile(targetPath, targetFilename, containerName, filename, append);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: EdgeHub-DownloadFileHandler '{0}'", ex.Message);
            }
            finally
            {
                ModuleClient mc = (ModuleClient)context;
                await mc.CompleteAsync(message);
            }

            return(MessageResponse.Completed);
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> DownloadFile(string path, string filename, string blobPath, string blobFilename, bool append = false)
        {
            try
            {
                await local.DownloadFile(path, filename, blobPath, blobFilename, append);

                return(new HttpResponseMessage(System.Net.HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError)); // { ReasonPhrase = ex.Message };
            }
        }