0

I use OKHTTP3 library to upload files to my http file server.

I found this code to do this and it works fine.

But I also want to just create a new folder without file.

Does anybody know how to create the request?

        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();

1 Answers1

0

My Http File Server is in default configuration. I didn't set up any script, because I don't understand the process(see on https://rejetto.com/wiki/index.php?title=HFS:_Event_scripts)

Thank you

  • Please use the space dedicated to answers, only for answers :) You can clarify any doubt of the community by making a comment and not an answer. Also, if applicable, you can edit your question. – Andre Nevares Aug 14 '22 at 19:19