Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过http 2请求发送WAV文件-Android Studio_Java_Android Studio_Httprequest_Retrofit2_Wav - Fatal编程技术网

Java 通过http 2请求发送WAV文件-Android Studio

Java 通过http 2请求发送WAV文件-Android Studio,java,android-studio,httprequest,retrofit2,wav,Java,Android Studio,Httprequest,Retrofit2,Wav,我在一台使用WAV文件的服务器上运行一个机器学习模型。我可以通过Android Studio的HTTP请求以WAV格式发送手机中存储的WAV文件吗 到目前为止,我使用改型2发出(获取)请求,如下所示: MainActivity.java: private void getbuttonclicked() { Call call = RequestManager.INSTANCE.getService().getChords(); call.enqueue((Callback)(ne

我在一台使用WAV文件的服务器上运行一个机器学习模型。我可以通过Android Studio的HTTP请求以WAV格式发送手机中存储的WAV文件吗

到目前为止,我使用改型2发出(获取)请求,如下所示:

MainActivity.java:

private void getbuttonclicked() {
    Call call = RequestManager.INSTANCE.getService().getChords();
    call.enqueue((Callback)(new Callback() {public void onResponse(@NotNull Call call, @NotNull Response response) {
        Intrinsics.checkParameterIsNotNull(call, "call");
        Intrinsics.checkParameterIsNotNull(response, "response");
        if (response.isSuccessful()) {
            ((TextView) findViewById(R.id.output_text)).setText("REQUEST OK");
        }
    }
DataManager.kt:

object RequestManager {
    val interceptor = HttpLoggingInterceptor()
    val client = OkHttpClient.Builder().addInterceptor(interceptor).build()


    init {
        interceptor.level = HttpLoggingInterceptor.Level.BODY
    }

    val retrofit = Retrofit.Builder()
            .baseUrl("http://myip/")
            .addConverterFactory(GsonConverterFactory.create())
            .client(client)
            .build()

    val service = retrofit.create(Api::class.java)

}
Api.kt:

interface Api {
    @GET(".")
    fun getChords(): Call<chord_model>
}
接口Api{
@获取(“.”)
fun getChords():调用
}
chord_model.java:

public class chord_model {
    @SerializedName("Chords")
    @Expose
    private List<String> chords = null;
    @SerializedName("Bass")
    @Expose
    private List<String> bass = null;

    public List<String> getChords() {
        return chords;
    }

    public void setChords(List<String> chords) {
        this.chords = chords;
    }

    public List<String> getBass() {
        return bass;
    }

    public void setBass(List<String> bass) {
        this.bass = bass;
    }

}
公共类chord\u模型{
@序列化名称(“和弦”)
@暴露
私有列表和弦=null;
@序列化名称(“低音”)
@暴露
私有列表bass=null;
公共列表getchord(){
回音和弦;
}
公共无效设置和弦(列表和弦){
这个和弦=和弦;
}
公共列表getBass(){
返回低音;
}
公共无效挫折(列表低音){
这个低音=低音;
}
}

我想我必须使用post请求,但如何发送整个文件?

您应该查看本文:

基本上,您将发送一个POST请求。使用邮递员,它会是这样的: