質問編集履歴
2
試した内容更新しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,6 +52,8 @@
|
|
52
52
|
|
53
53
|
Public Function PostValue() As HttpResponseMessage
|
54
54
|
|
55
|
+
Dim strPhotoId As String
|
56
|
+
|
55
57
|
Dim stream As IO.Stream
|
56
58
|
|
57
59
|
Dim intByteLen As Integer = synova.Dotnet.Common.Lib.F_NullToInteger(Request.Content.Headers.GetValues("Content-Length")(0).ToString)
|
@@ -70,38 +72,68 @@
|
|
70
72
|
|
71
73
|
End If
|
72
74
|
|
75
|
+
Return Request.CreateResponse(HttpStatusCode.Accepted, strPhotoId)
|
76
|
+
|
77
|
+
|
78
|
+
|
73
79
|
End Function
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
###試したこと
|
84
|
+
|
85
|
+
ソースをいったん直しましたので変更致します。
|
86
|
+
|
87
|
+
streamでバイトまでは取れてるようなのですが、取得したバイトを
|
88
|
+
|
89
|
+
そのままイメージに保存した場合エラーが発生しています。
|
90
|
+
|
91
|
+
元のファイルのバイト数が17,525に対して
|
92
|
+
|
93
|
+
読込んだ際のバイト数が17,718になっています。
|
94
|
+
|
95
|
+
不要なデータが存在するってことでしょうか?
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
以下Fidderでファイルをアップした際の内容です。
|
100
|
+
|
101
|
+
<POST>
|
102
|
+
|
103
|
+
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
|
104
|
+
|
105
|
+
User-Agent: Fiddler
|
106
|
+
|
107
|
+
Host: localhost
|
108
|
+
|
109
|
+
Content-Length: 17718
|
74
110
|
|
75
111
|
|
76
112
|
|
77
113
|
|
78
114
|
|
79
|
-
|
115
|
+
<RAWタブの情報>
|
80
116
|
|
81
|
-
|
117
|
+
POST http://localhost/WebApplication2/photos HTTP/1.1
|
82
118
|
|
83
|
-
|
119
|
+
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
|
120
|
+
|
121
|
+
User-Agent: Fiddler
|
122
|
+
|
123
|
+
Host: localhost
|
124
|
+
|
125
|
+
Content-Length: 194
|
84
126
|
|
85
127
|
|
86
128
|
|
87
|
-
|
129
|
+
---------------------------acebdf13572468
|
88
130
|
|
89
|
-
|
131
|
+
Content-Disposition: form-data; name="fieldNameHere"; filename="test.jpeg"
|
90
132
|
|
91
|
-
Content-
|
133
|
+
Content-Type: image/jpeg
|
92
|
-
|
93
|
-
Host: localhost
|
94
|
-
|
95
|
-
Content-Type: multipart/form-data;boundary=------FormBoundaryShouldDifferAtRuntime
|
96
134
|
|
97
135
|
|
98
136
|
|
99
|
-
------FormBoundaryShouldDifferAtRuntime--
|
100
137
|
|
101
138
|
|
102
|
-
|
103
|
-
リクエストした方で
|
104
|
-
|
105
|
-
{"Message":"エラーが発生しました。","ExceptionMessage":"型 'LazyStreamContent' のオブジェクトを型 'System.Net.Http.StreamContent' にキャストできません。
|
106
|
-
|
107
|
-
|
139
|
+
---------------------------acebdf13572468--
|
1
サーバー側のソースを追記致しました。パケットのログは取得してアップします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,6 +36,44 @@
|
|
36
36
|
|
37
37
|
```
|
38
38
|
|
39
|
+
Imports System.Net
|
40
|
+
|
41
|
+
Imports System.Web.Http
|
42
|
+
|
43
|
+
Imports System.Net.Http
|
44
|
+
|
45
|
+
Imports Newtonsoft.Json
|
46
|
+
|
47
|
+
Imports System.Drawing
|
48
|
+
|
49
|
+
Imports System.IO
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Public Function PostValue() As HttpResponseMessage
|
54
|
+
|
55
|
+
Dim stream As IO.Stream
|
56
|
+
|
57
|
+
Dim intByteLen As Integer = synova.Dotnet.Common.Lib.F_NullToInteger(Request.Content.Headers.GetValues("Content-Length")(0).ToString)
|
58
|
+
|
59
|
+
Dim saveFileBytes(intByteLen) As Byte
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
stream = Request.Content.ReadAsStreamAsync().Result
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
If stream.CanRead = True Then
|
68
|
+
|
69
|
+
stream.ReadAsync(saveFileBytes, 0, intByteLen)
|
70
|
+
|
71
|
+
End If
|
72
|
+
|
73
|
+
End Function
|
74
|
+
|
75
|
+
|
76
|
+
|
39
77
|
|
40
78
|
|
41
79
|
###試したこと
|