English 中文(简体)
B. 改换动态理论,以内联网进入Sting和返回Buffer
原标题:Changing DynamicChannelBuffer in Netty to String and back to ChannelBuffer

我的网络服务器在Schala使用Twitter s Finagle图书馆书写,而后者则依靠Netty。 因此,请求内容作为动态的ChannelBuffer归还。 如果我把图像从终端站上载到服务器,就如:

 curl -T "abc.jpg" http://127.0.0.1:8080/test/image

然后,我可以读一下,把图像传给一个支持的网络服务器,使用一个SAP包,看上去:

      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <AuthHeader xmlns="http://www.testtesttest.co.za/">
            <LogonID>testtesttest</LogonID>
            <Password>testtesttest</Password>
          </AuthHeader>
        </soap:Header>
        <soap:Body>
          <uploadFile xmlns="http://www.testtesttest.co.za/">
            <FileDetails>
               <FileName>image.jpg</FileName>
              <FileContents>
                 {(Base64.encode(request.getContent())).toString(UTF_8)
              </FileContents>
            </FileDetails>
          </uploadFile>
        </soap:Body>
      </soap:Envelope>

在上述例子中,该代码:(Base64.encode(request.getContent()))。toString(UTF_8)将申请内容转换为第64条编码说明。

问题在于,我需要阅读从移动电话发送的多端Http申请中得出的图像内容。 TelephoneGap给我别无选择,只能寄送图像,并坚持作为多部分要求进行文件上载。

To break the multipart request apart, I change the request.getContent() result into a string using toString(UTF_8), and then getting the image data part by splitting the http multipart message into it s separate chunks:

 var requestParts = request.content.toString(UTF_8).split("\Q--*****org.apache.cordova.formBoundary\E")
 val imageParts = requestParts(3).split("\n\s*\n")
 val imageHeader = imageParts(0)
 val imageBody = imageParts(1)

我知道,这是令人不安的,但现在却看不到。 如今,图像具有显示图像的内容。

Now, if I put the imageBody back into the SOAP packet, I have to encode it again using:

 val encoder = new BASE64Encoder();
 val encodedImage = encoder.encode(imageBody)

此时此刻,形象只是空洞的。 它的规模看上去是正确的,但我说的是,大刀阔.的转换或编码。 例如,Im使用Netty s encoder,但第二种情况是Im使用标准java encoder。 原因是,Netty s encoder只能装上海峡牌照的物体。

我不想这样说太大了,但我今天一直在为此而努力。 这里的任何帮助都将受到全球教育研究基金会的赞赏。

最佳回答

因此,这项工作:

image --> [curl] ------> post1 -->  [your code] --> soap msg 1 --> [back-end]

这并不是:

image --> [phonegap] --> post2 -->  [your code] --> soap msg 2 --> [back-end]

为了可靠地解决这类问题,你需要了解每个步骤使用哪些编码。

假设你能使用同样的形象,你能否检查1号邮局和2号邮局的原始编码内容,以及正在使用哪些编码? 然后,如果你理解,将内容登录在your Code上,作为编码和重新编码信息。 这样,你就可以在Sap msg1上确保这一点。

问题回答

暂无回答




相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...