这是客户端错误
Refit.ApiException
Message=Response status code does not indicate success: 413 (Payload Too
Large).
Source=mscorlib
StackTrace:
at Refit.RequestBuilderImplementation+<>c__DisplayClass14_0`2[T,TBody].
<BuildCancellableTaskFuncForMethod>b__0 (System.Net.Http.HttpClient client,
System.Threading.CancellationToken ct, System.Object[] paramList) [0x002bd]
in <cda9777f03ee4e9188064495e9f2e568>:0
at Kula.Addprofilepicture.Postbase (System.Byte[] base64strings) [0x0002b] in
C:UsersblainDesktopKula2KulaaaKulaKulaAddprofilepicture.xaml.cs:81
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.
<ThrowAsync>b__7_0 (System.Object state) [0x00000] in
<19853c43ab794d18ab1a33ecb65b3c4d>:0
at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in
<8c07a09624c14764b43f6b946a5a1f23>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in
`enter code here` <8c07a09624c14764b43f6b946a5a1f23>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr
native__this) [0x00009] in <8c07a09624c14764b43f6b946a5a1f23>:0
at (wrapper dynamic-method)
Android.Runtime.DynamicMethodNameCounter.43(intptr,intptr)
服务器端错误
PayloadTooLargeError: request entity too large
at IncomingMessage.onData
(C:UsersblainDesktopKulaaBackendnode_modulesraw-bodyindex.js:246:12)
at IncomingMessage.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at IncomingMessage.Readable.push (_stream_readable.js:223:10)
at HTTPParser.parserOnBody (_http_common.js:128:22)
服务器端代码
app.post('/Phototest', (request, response) =>{
console.log('request tried');
console.log(request);
})
发布字节码
public async void Postbase(byte[] base64strings) {
/*
base64s s = new base64s()
{
base64string = base64strings
};
string stringpayload = JsonConvert.SerializeObject(s);
await apiRequestHelper.RequestSaveProfilephotoAsync(stringpayload);
*/
await myAPI.PostProfilePhoto(base64strings);
}
这是改装帖子 我也停止了对它的 URL 编码,因为我认为这可能会使它太大。 所以我只是将其作为字节发送,仅此而已。 将来我可能需要用它发送电子邮件或令牌。
[Post("/Phototest")]
Task<string> PostProfilePhoto(Byte[] data);
如果您知道一种更好的格式来发送它,那就太短了,因为我将不得不为将来发送到服务器的数据量付费。
app.use(bodyParser.json({limit:'5000mb'}((; app.use(bodyParser.urlencoded({limit:'5000mb',extended: true}((; 解决了我的问题
试试吧!它对我有用。快递 v4 app.use(express.json({limit: '50MB'}((; app.use(express.urlencoded({limit: '50MB'}((;