相关疑难解决方法(0)

如何从URI获取完整文件路径

我想从URI获取完整的文件路径.URI不是图像,但它是一个音乐文件,但如果我像MediaStore解决方案一样,如果应用程序用户选择例如Astro作为浏览器而不是音乐播放器,它将无法工作.我该如何解决这个问题?

android uri get path

86
推荐指数
8
解决办法
18万
查看次数

如何将InputStream张贴为Retrofit中的请求主体?

我正在尝试使用类似于以下内容的InputStream来执行POST:

@POST("/build")
@Headers("Content-Type: application/tar")
Response build(@Query("t") String tag,
               @Query("q") boolean quiet,
               @Query("nocache") boolean nocache,
               @Body TypedInput inputStream);
Run Code Online (Sandbox Code Playgroud)

在这种情况下,InputStream来自压缩的tar文件。

张贴InputStream的正确方法是什么?

rest docker retrofit

5
推荐指数
2
解决办法
7090
查看次数

无法将图片从Android上传到java服务器

我一直在努力通过Android Retrofit + SpringMVC实现个人资料照片上传功能.Java服务器无法响应Retrofit API调用.相关代码段如下:

ApiInterface

@Multipart
@POST("user/profileImage")
Call<ResponseBody> uploadImage(@Part MultipartBody.Part image, @Part("name") RequestBody name);
Run Code Online (Sandbox Code Playgroud)

uploadToServer

public void uploadToServer(){
    //Get retrofit client
    Retrofit retrofit = ApiClient.getClient();
    //Get API interface
    ApiInterface apiInterface = retrofit.create(ApiInterface.class);
    // Get image parts
    MultipartBody.Part imageParts = bitmapToMultipart(imageBitmap);
    //Get image name
    RequestBody name = RequestBody.create(MediaType.parse("text/plain"), "ProfileImage");
    //Call image upload API
    Call<ResponseBody> call = apiInterface.uploadImage(imageParts,name);
    call.enqueue(new Callback<ResponseBody>() {
        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            ResponseBody body = response.body();
        }

        @Override
        public void onFailure(Call<ResponseBody> call, Throwable t) …
Run Code Online (Sandbox Code Playgroud)

java android spring-mvc retrofit

5
推荐指数
1
解决办法
562
查看次数

导入已在单一类型导入中定义

我需要帮助来弄清楚如何解决我的活动中两个相互冲突的导入的问题,即:

  1. retrofit2.Response
  2. com.android.volley.Response

第一个导入是为了帮助我管理 api 回调响应,而第二个是为了帮助我在上传文件时管理 stringrequest 响应。单独实现一个,即只运行 api 调用来获取数据本身就可以正常工作,就像自己上传文件一样。现在将两者合并为一个活动,这样当用户从下拉列表中选择数据时,其列表来自服务器,然后上传文件已被证明是非常麻烦的错误:

retrofit2.Response 已在单一类型导入中定义

或者

com.android.volley.Response 已在单一类型导入中定义

取决于哪个先到。

import android response

4
推荐指数
2
解决办法
7746
查看次数

标签 统计

android ×3

retrofit ×2

docker ×1

get ×1

import ×1

java ×1

path ×1

response ×1

rest ×1

spring-mvc ×1

uri ×1