3

如何通过改造上传音频文件?

我带了一些自己写的类和代码,但是这些代码我都没有响应

界面:

 @Multipart
    @POST("comments")
    Call<Wallet> setComent(@Part("voice") RequestBody song, @Part("api_token") String api_token, @Part("product") String product, @Part("body") String body);

班级 :

 AudioSavePathInDevice =
                Environment.getExternalStorageDirectory().getAbsolutePath() + "/" +
                        "NAME" + "AudioRecording.mp3";


    File file = new File(AudioSavePathInDevice );

                    //creating request body for file
                    RequestBody requestFile = RequestBody.create(MediaType.parse("audio/*"), file);

                    MyInterFace myInterFace = MyServices.createService(MyInterFace.class);
                    Call<Wallet> calling = myInterFace.setComent
                            (requestFile,new AppStore(getContext()).LoadMyShereKES(AppStore.Keys_TOKEN),AppStore.ID_BACHGROUD,Ediet.getText().toString());

                    calling.enqueue(new Callback<Wallet>()
                    {
                        @Override
                        public void onResponse( Call<Wallet> call,  Response<Wallet> response)
                        {
                            appStore.CloseDilag();
                        }

                        @Override
                        public void onFailure(Call<Wallet> call, Throwable t)
                        {

                            appStore.CloseDilag();
                        }
                    });

在此处输入图像描述

4

1 回答 1

0

所有文件,无论是音频、视频、图像……都基本相同,可以进行改造。它们只是文件。@MultiPart.Part与任何其他文件一样,该界面也带有注释。检查链接以获取更多详细信息。

于 2021-01-25T18:36:18.717 回答