我使用OKHTTP3库将文件上传到我的http文件服务器。
我找到了这样做的代码,它工作得很好。
但是我也想创建一个没有文件的新文件夹。
有人知道如何创建请求吗?
OkHttpClient client = new OkHttpClient.Builder()
.authenticator(new Authenticator() {
@Override
public Request authenticate(Route route, Response response) throws IOException {
String credential = Credentials.basic(username,password);
return response.request().newBuilder()
.header("Authorization", credential)
.build();
}
})
.build();
RequestBody formBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(),
RequestBody.create(MediaType.parse("text/plain"), file))
.addFormDataPart("other_field", "other_field_value")
.build();
Request request = new Request.Builder().url(url).post(formBody).build();
Response response = client.newCall(request).execute();发布于 2022-08-10 15:14:25
我的Http文件服务器处于默认配置状态。我没有设置任何脚本,因为我不理解这个过程(参见https://rejetto.com/wiki/index.php?title=HFS:_Event_scripts)
谢谢
https://stackoverflow.com/questions/73295159
复制相似问题