0

我使用 xamarin 表单制作多平台应用程序,我想在服务器中上传图片,但是当我上传所有图片时,我的应用程序速度非常慢。

我使用 WebClient 发出请求。有我的上传功能:

public static async Task<string> CreateUploadTask(string File, string vtour_id, string user_id, string user_login)
        {
            string requestResult = "";
            using (WebClient client = new WebClient())
            {
                // add event listeners
                client.UploadProgressChanged += Client_UploadProgressChanged;

                // set the file type
                client.Headers.Add("Content-Type", "image/jpeg");
                // upload the file
                byte[] response = await client.UploadFileTaskAsync(Database.URL_DATABASE + "uploadPicture", "POST", File);

                // delete the event listeners
                client.UploadProgressChanged -= Client_UploadProgressChanged;

                requestResult = client.Encoding.GetString(response);
                client.Dispose();
            }

            return requestResult;
        }

之后导航非常慢。

我该如何改善呢?

谢谢!

4

0 回答 0