Flutter App将图像上传到Debian服务器,但是图像不会在网络浏览器中刷新,除非重新启动

问题描述

我正在上传一个图像,该图像将覆盖服务器上的图像。但是,当我尝试刷新服务器IE https://example.com/image.jpg上的网页时,图像不会刷新,并且旧图像仍然保留。但是,如果我重新启动Android Studio中的Flutter程序,然后刷新网页,则图像会刷新,并且可以看到新上传的图像。有人知道发生了什么吗?为什么服务器上的图像状态会受到Flutter应用程序状态的影响?我如何才能刷新它并在网页上显示上传的图像,而不必热重启Flutter应用程序?

这是我上传图片的方式;

Future<String> uploadAvatar(
    {String currentuserid,String filepath}) async {

   const serverurl = "https://example.com/uploadAvatar.PHP";

  final request = http.MultipartRequest('POST',Uri.parse(serverurl));
  request.fields['currentuserid'] = currentuserid;

  final multipartfile = await http.multipartfile.fromPath("photo",filepath,contentType: MediaType("photo","jpg"));
        request.files.add(multipartfile);

                if (response.statusCode == 200) {                
                //
                     }
                return response.body;    
                }

这是热重启时发生的事情;

Future<List<SpeakContent>> downloadMainjsON(
    {String stagetype,String currentagname,String currentaudioid,String search,int refreshIndex,BuildContext context
    }) async {
  String jsonContent ="https://example.com/getContent.PHP"  

  final response = await get(jsonContent);

  if (response.body.contains('audioid')) {
    List speakcrafts = json.decode(response.body);
    return speakcrafts.map((speakcraft) => SpeakContent.fromJson(speakcraft)).toList();
  }
    else if (search != null) {
    String textResult = "Search words not found. Try again.";
    Navigator.pop(context,textResult );
    }
    else
    throw Exception('We were not able to successfully download the json data.');
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)