1

这是客户端错误

 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:\Users\blain\Desktop\Kula2\Kulaaa\Kula\Kula\Addprofilepicture.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:\Users\blain\Desktop\KulaaBackend\node_modules\raw-body\index.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);

如果您知道一种更好的格式来发送它,那将是很棒的,因为我将不得不为将来发送到服务器的数据量付费。

4

2 回答 2

1

app.use(bodyParser.json({limit:'5000mb'})); app.use(bodyParser.urlencoded({limit:'5000mb',extended: true})); 解决了我的问题

于 2019-12-04T05:46:05.943 回答
0

试试看!它对我有用。Express v4 app.use(express.json({limit: '50mb'})); app.use(express.urlencoded({limit: '50mb'}));

于 2021-01-23T08:24:27.547 回答