OSDN Git Service

アイコンアップロードでmime指定するように。
authorkiri_feather <kiri_feather@users.sourceforge.jp>
Thu, 3 Jun 2010 18:40:53 +0000 (18:40 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:13:12 +0000 (23:13 +0900)
encodingの指定削除

git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@438 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Connection/HttpConnection.vb

index 353cc32..24cbe02 100644 (file)
@@ -130,11 +130,24 @@ Public Class HttpConnection
                 If binaryFileInfo IsNot Nothing Then
                     For Each kvp As KeyValuePair(Of String, FileInfo) In binaryFileInfo
                         Dim postData As String = ""
+                        Dim mime As String = ""
+                        Select Case kvp.Value.Extension.ToLower
+                            Case ".jpg", ".jpeg"
+                                mime = "jpeg"
+                            Case ".gif"
+                                mime = "gif"
+                            Case ".png"
+                                mime = "png"
+                        End Select
+                        'postData = "--" + boundary + vbCrLf + _
+                        '        "Content-Disposition: form-data; name=""" + kvp.Key + """; filename=""" + _
+                        '        kvp.Value.Name + """" + vbCrLf + _
+                        '        "Content-Type: image/" + mime + vbCrLf + _
+                        '        "Content-Transfer-Encoding: binary" + vbCrLf + vbCrLf
                         postData = "--" + boundary + vbCrLf + _
                                 "Content-Disposition: form-data; name=""" + kvp.Key + """; filename=""" + _
                                 kvp.Value.Name + """" + vbCrLf + _
-                                "Content-Type: application/octet-stream" + vbCrLf + _
-                                "Content-Transfer-Encoding: binary" + vbCrLf + vbCrLf
+                                "Content-Type: image/" + mime + vbCrLf + vbCrLf 
                         Dim postBytes As Byte() = Encoding.UTF8.GetBytes(postData)
                         reqStream.Write(postBytes, 0, postBytes.Length)
 
@@ -155,6 +168,7 @@ Public Class HttpConnection
                 Dim endBytes As Byte() = Encoding.UTF8.GetBytes(vbCrLf + "--" + boundary + "--" + vbCrLf)
                 reqStream.Write(endBytes, 0, endBytes.Length)
                 reqStream.Close()
+                'webReq.ContentLength = len
             End Using
         End If
         'cookie設定