<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: ListenHTTP processor in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134422#M97081</link>
    <description>&lt;P&gt;thank you it worked&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2016 16:51:04 GMT</pubDate>
    <dc:creator>afdebbas</dc:creator>
    <dc:date>2016-12-05T16:51:04Z</dc:date>
    <item>
      <title>ListenHTTP processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134420#M97079</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to send a file over http to nifi. When i do so, the filename attributes is set to a long sequence of numbers as shown below in the picture. How should my http url be? &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/10040-listenhttpflowfile.jpg"&gt;listenhttpflowfile.jpg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;this is the code im working with &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Code Sample as below:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;  public string PutNifi(string filePath)
        {
            // Create a http request to the server endpoint that will pick up the
            // file and file description.
            string Message = "Failed";
            try
            {
                HttpWebRequest requestToServerEndpoint = (HttpWebRequest)WebRequest.Create("http://db-hdf:8081/contentListener");


                string boundaryString = "----SomeRandomText";
                string fileUrl = filePath;


                // Set the http request header \\
                requestToServerEndpoint.Method = WebRequestMethods.Http.Post;
                requestToServerEndpoint.ContentType = "multipart/form-data; boundary=" + boundaryString;
                requestToServerEndpoint.KeepAlive = true;
                requestToServerEndpoint.Credentials = System.Net.CredentialCache.DefaultCredentials;


                // Use a MemoryStream to form the post data request,
                // so that we can get the content-length attribute.
                MemoryStream postDataStream = new MemoryStream();
                StreamWriter postDataWriter = new StreamWriter(postDataStream);


                // Include the file in the post data
                postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
                postDataWriter.Write("Content-Disposition: form-data;"
                                        + "name=\"{0}\";"
                                        + "filename=\"{1}\""
                                        + "\r\nContent-Type: {2}\r\n\r\n",
                                        "myFile",
                                        Path.GetFileName(fileUrl),
                                        Path.GetExtension(fileUrl));
                postDataWriter.Flush();


                // Read the file
                FileStream fileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read);
                byte[] buffer = new byte[1024];
                int bytesRead = 0;
                while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                {
                    postDataStream.Write(buffer, 0, bytesRead);
                }
                fileStream.Close();


                postDataWriter.Write("\r\n--" + boundaryString + "--\r\n");
                postDataWriter.Flush();


                // Set the http request body content length
                requestToServerEndpoint.ContentLength = postDataStream.Length;


                // Dump the post data from the memory stream to the request stream
                using (Stream s = requestToServerEndpoint.GetRequestStream())
                {
                    postDataStream.WriteTo(s);
                }
                postDataStream.Close();
                Message = "Success";
            }
            catch (Exception ee)
            {
                Message = ee.ToString();
            }
            return Message;
        }
    }
&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Dec 2016 20:29:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134420#M97079</guid>
      <dc:creator>afdebbas</dc:creator>
      <dc:date>2016-12-02T20:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: ListenHTTP processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134421#M97080</link>
      <description>&lt;P&gt;If you send a header named "filename" it should respect that value for the filename attribute in NiFi:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/servlets/ListenHTTPServlet.java#L243-L246" target="_blank"&gt;https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/servlets/ListenHTTPServlet.java#L243-L246&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Basically HTTP headers become FlowFile attributes, and the body of the HTTP request becomes FlowFile content.&lt;/P&gt;&lt;P&gt;Write now it looks like you are writing the filename into the body of the POST request.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 22:28:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134421#M97080</guid>
      <dc:creator>bbende</dc:creator>
      <dc:date>2016-12-02T22:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: ListenHTTP processor</title>
      <link>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134422#M97081</link>
      <description>&lt;P&gt;thank you it worked&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 16:51:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/ListenHTTP-processor/m-p/134422#M97081</guid>
      <dc:creator>afdebbas</dc:creator>
      <dc:date>2016-12-05T16:51:04Z</dc:date>
    </item>
  </channel>
</rss>

