我送的圖像,並使用改進的描述到服務器,但我無法解決FileUtils.getFile方法GetFile方法來發送圖片和描述到服務器。如何使用改裝2.0
這裏是我的代碼:
gradle這個:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.github.boxme:squarecamera:1.1.0'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.support:design:24.2.1'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile('org.apache.httpcomponents:httpmime:4.2.4')
compile 'com.pnikosis:materialish-progress:1.7'
}
活動:
@NonNull
private MultipartBody.Part prepareFilePart(String partName, Uri fileUri) {
// https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java
// use the FileUtils to get the actual file by uri
File file = FileUtils.getFile(this, fileUri);// here i am not able to resolve getFile method
// create RequestBody instance from file
RequestBody requestFile =
RequestBody.create(
MediaType.parse(context.getContentResolver().getType(fileUri)),
file
);
return MultipartBody.Part.createFormData(partName, file.getName(), requestFile);
}
哪裏該類從何而來?你去過那個類的API文檔? –