我正在使用smack 4.2.3版本并在聊天中使用HttpFileUploadManager,我的代码如下: HttpFileUploadManager httpFileUploadManager = HttpFileUploadManager.getInstanceFor(XMPPSession.mXMPPConnection); httpFileUploadManager.requestSlot(content,file.length(),“ upload。” +“ localhost”); 网址sendurl = httpFileUploadManager.uploadFile(file,new UploadProgressListener(){ @Override public void onUploadProgress(long l,long l1){ uploadProgress =(float)l /(float)l1; if(uploadProgress == 1.0f){ uploadProgress = 0; } } }); 注意:但这会返回403禁止错误。 07-15 19:47:34.485 16800-23354 / higuys.com.higuys W / System.err:java.io.IOException:文件上传期间来自服务器的错误响应403:禁止,文件大小:167700,放置URL:{{ 3}} 07-15 19:47:34.486 16800-23354 / higuys.com.higuys W / System.err:at org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager.uploadFile(HttpFileUploadManager.java:464) 在org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager.uploadFile(HttpFileUploadManager.java:261) 在higuys.com.higuys.ChatActivity $ 20.run(ChatActivity.java:917) 在android.os.Handler.handleCallback(Handler.java:751) 在android.os.Handler.dispatchMessage(Handler.java:95) 在android.os.Looper.loop(Looper.java:154) 在higuys.com.higuys.Services.DispatchQueue.run(DispatchQueue.java:74)