public async Task <HttpResponseMessage> WriteFile([FromBody] byte[] body, string path, string filename, bool append) { try { await local.WriteFile(path, filename, body, append); return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)); } catch (Exception ex) { Console.WriteLine(ex.Message); return(new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError)); //{ ReasonPhrase = ex.Message }; } }
public async Task <MessageResponse> WriteFileHandler(Message message, object context) { try { string sourcePath = message.Properties["path"]; string sourceFilename = message.Properties["filename"]; bool append = message.Properties.ContainsKey("append") ? Convert.ToBoolean(message.Properties["append"]) : false; byte[] content = message.GetBytes(); await local.WriteFile(sourcePath, sourceFilename, content, append); } catch (Exception ex) { Console.WriteLine("ERROR: EdgeHub-WriteFileHandler '{0}'", ex.Message); } finally { ModuleClient mc = (ModuleClient)context; await mc.CompleteAsync(message); } return(MessageResponse.Completed); }