Android:414尝试将图像发送到服务器时,请求URL太长

时间:2016-08-27 09:53:19

标签: android bitmap base64 encode

我在尝试发送已编码的图片Bitmap时遇到此问题。

我认为这是由Base64.encodeToString()

的输出引起的

以下是我转换Bitmap图片的方式:

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100,byteArrayOutputStream);
                byte [] bytes = byteArrayOutputStream.toByteArray();

                mPathImage = Base64.encodeToString(bytes, Base64.DEFAULT);

编码的输出转到:

/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
                                                      AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
                                                      AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCADMAJkDASIA
                                                      AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
                                                      AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
                                                      ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
                                                      p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
                                                      AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
                                                      BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
                                                      U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
                                                      uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD8zbPx
                                                      J4nlhZ5buwglk8hlSOEnbGY2l8t5EbPmRykR8PLDIgDoN5yHJqWvExvd6+yRKYpDBbWiojSLKzuv
                                                      2h5nZUeIvGu6IMX2SNsuGZ28fj8T3h+0SeUkZRIyJGuYWiB83EkshdlERKRDz1G5d/Ec7xyNNV4a
                                                      7ebX2SeUwljYGNUWIwF5AVkhkFxulRCodIzG0kfzGaNpFVf6vli43e3S6b11cttdrJO/X3tHbX+b
                                                      44GEVdQgr2itNUtbSW7jo1s9E0ru8m/dI9WKO4aUkOBIpLruGCyLlZCAHUKpZF+58u1ypaQ6EOsp
                                                      kyGVPu4feZCqb2cRlMn5ME5EikhQXXccFj4Ta6zLJP5jXb3EcUkrvC7yBVWPf5IH2VrZpGjD4nkd
                                                      pIpo4ocwKxlkfdj8UpGzRww2qfKEaZwu55NwwUE5kCNIyBj5YBfzJImZU3FuOeMerUlFaaW/vS1d
                                                      9btaJrz1slalhWlJRlommtNebVXu3tb52to2j1jR9da3+ImnShht1Pw5fafCmWZw9pfw3Rd8ylH2
                                                      wygncF2sQGPls617jZ6uvn5nn2sd6MXUFRk+a/MEmzdlBuc5AUKwJZW3/E48aXNt418Fo16RZXdz
                                                      q9ncIsUKxSSy6a0tkmUjEj/vkfanyyM+wsSQj17raa3NJc2my5WJftazP/rHaQYuFMAMrMFSctGR
                                                      INzLmQriQKa6MBXUlUXNf302730bem9+ny2bTaT4cVSqRT5rv3GtE7XTacrp63Tj6NLqmfQY1fcF
                                                      2lQ4QL5Tuoj2KzOAisfnfOVKsQjYdtoyoLJNTCwRyIyO0kkymFSqOiW8cA8xkJMjCQkmKTarlo5I
                                                      wUUOa81j8SPBBMkMSzzXcRgCFiGCC4W4RhK6usbStCIg8x8kMUidEklWaoo9dieNvM8vfGNqRpKJ
                                                      WjRXOG7eUrKIlGEYb5kABQNI3qqfLqna+l++qW9+vf11e55bgpK8mo25VFvq7STer03su63dmmek
                                                      nWGdXwwAXnGJEAc+dHG+whcAkEudpGCJGfefMakmsueGcyK4JKiU7f8AWuBt5y0JV2RkUujMVcgE
                                                      Hb5nL4rtF3q14qZjkV8uXG5MCbYFkcFVUKpSPrISSAEeM5B8XWRYtFciXO0ptUIBvQOoR1GUAA+7
                                                      k5OOojSZYdSC3l8tbvVrRW8vxWrs2HJFStzatRTSvfS6urNuzt112u9bv1j+2ZItxdiZMHcA4KkN
                                                      JhmQsCN38WSu7eyAMCBmSPV0xI0UhDOpDbmjSEiRztXLM5LmJYifUFYQXU5PkDeJBIrzRCeUoQnk
                                                      xZlZSZfvJ9oaFWRg6sH3BUUSAyAKSaMviidwhjjIDqhIldYSdzbF8xik2M5PzIWkUIAcHcGh1o7J
                                                      3fXTXv39E799NVJmkE/Pla0um9U9H2jonZbvyad/XpdYkffulUAk4UJ8quikum5mDgk5I2SkEbmZ
                                                      GQLh8WtuUkUyqpyyoQ53s5ctuyNjCLg4IzuIEaOAFlrw0+JbkqCiwq25MiSQsm4RFiPkUlpFIcox
                                                      PmMsisWUrUS+Ir0uxklgSBzMMKG8/YGdVeSR5IlGT++O1EKkqiMGzle3haWkrxS0fXfZt66btX1s
                                                      nZocabUpybfvK22iV1Z6vXZLfq93JI91i1ncfKWQqrq6/NuYruB8vcrMrIVDPuDuoUAKwJLmnNqZ
                                                      KMg2eXsZ8KQG3LIUhAIlVNzq+1SrtKJhGUUbAa8COuXUlzIn9qEQnaoiW2tmkE291baJFLkTMd7F
                                                      ncCXdvZUUCrD6mCJd+r36gmIx+W6QojRGd12fZ0V0jKlVlVgZGTLKZCY56n6xBLmtuvXZve1/wCW
                                                      3f3o72d5cKjTUYt2sk3PRrmd7RvZK9nvfo07tr2m71fajxRzKmAcgbyYsCUl5AyFDvGCxRGMoY4Z
                                                      Y2Za43UdVj2uiy7kO5CcIVWVt26JpN+XLuMnkMdzo2Vkryq4kWeOeJtX1BUaZpDEt3HLFzMskca+
                                                      bFPt8kAIDyNqq7M7hXrAI06BJAZbyaSSNRJI84AQF3mkDeQkLL5hwZGcGQxg+UGI3HhninduOqvq
                                                      ttbvX4tOl79fV2ujh3JyUr3bjJXvZO7i1Z6Wf5PV2SZ3V/qlrGfMluY42cOyM8kS7gZHMoBYgYX+
                                                      IhioQFWAIkNYf9t6X/z83/8A4Dwf/Ga5GWe1giG0JNF5kzKJgXYyStLNKV84GSQySMxIZg7YkMyl
                                                      WJbP+0p6z/8AfiL/AApU8VO87Q5leNtbNapO+jvdW181vLff6koaNU1tbmi3dXdmnfTW+l2731u1
                                                      f5tbWYwzTx2zySk7XYXMsA3NkPGgmO8BxECCN8JDtud2R2a0fEV9xEUhgZ4o5QrTyuHDbtzEomQI
                                                      c4ikkcNIqv8AKXbdXkQ1FYnkZJ2cx+YsNxK6SSup+8vlozoA5UfICUMhdAyqkjB39p+XGpDsw3KV
                                                      YrIqxFhImOSFCLGrSkOMKQACzKXr5/67v7rfnpe9152/mevVpd5P7VYWy5W5Nq13bs52e71bW990
                                                      tG2ew2XiO4Xcs88ZkKxfu4eFVI2ByhcpJvcASMrK2SqIqs6eY2v/AMJCxWRmZuW+dXJJbeJUyqo2
                                                      5cqq7A7KuPMZZCJGDeGW2tCQuhdVZW3ksAjIy43fvHkQKxCqE8yTcqs5BZ9y1Zj1yZjswZFG4iRQ
                                                      j8kuAFaOVgcEsqt8zKxZShwK5niHKU3vsr31Wst1drW3y110adPBacyvfTpdtXey7vlbv0Wl319e
                                                      k1OS71fwkY44pksfFGkXkxku/ISO0WeSO5lLO8PnGESBo4xIxlbcJI3DMp+ix4kImtTEHcm8snOM
                                                      /IrXcYljXl3BWFJHZmVQyhm3KBID8ZadevNKN99YxNG6N+/uEgVUj3MNv2iSD95tCKoVmUhZypYo
                                                      RXp1z4s0OzsmuU12zmngw9vaiDUS7TxwyS8TR2ksKqWCoiSEKGcozqpnkHfgKrgpVNIxut5dU5Jt
                                                      Ju6ukvmo6u6Z5mLwqn+6g5c1tNLtNtpXVn/L9zad2nI+sNS1SeymutP1KOa0vbaW4sr/AE29guI7
                                                      q1uEmmguba7gkjSWGe3nBW4hlRbiGVXRlRkDNzcniCCSMxyJFKzII2hiLiIIoERG5t4ZPLjD7sEB
                                                      Wjj2hkC18Pa58WfGt/qN3eP4naO3mfbBa2ek6YTb20cjpZWguL

请帮助解决此问题。提前谢谢

更新:我一直使用POST方法发送图片

1 个答案:

答案 0 :(得分:2)

您在致电GET时是否提出了REST API请求?如果是这样,那就有限制了。

使用POST方法更新服务器中的图像

您可以查看此链接了解更多信息: Android : 414 Request-URL too long