-
multipart form-data 와 boundary
2022.08.08 - OkHttp 파일 전송(Multipart)
2022.08.13 - Http 파일 전송(Multipart)과 File Explorer
Intent data = new Intent(Intent.ACTION_OPEN_DOCUMENT); data.addCategory(Intent.CATEGORY_OPENABLE); String[] mimeTypes = {"*/*"}; data.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); data = Intent.createChooser(data, "파일 선택");
mAtvRstObj = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() { @Override public void onActivityResult(ActivityResult result) { if (result.getResultCode() == Activity.RESULT_OK) { Intent data = result.getData(); mUri = data.getData(); //MainActivity.this.mUri; String fn = getFileNameFromUri(mUri); Toast.makeText(getApplicationContext(), fn, Toast.LENGTH_LONG).show(); //check selected file if (mAtvRstObj.toString() != null) { qv(fn); } } } });
InputStream is = getContentResolver().openInputStream(mUri); sendfn = getApplicationContext().getExternalFilesDir("")+"Test.dat";
RequestBody reqMpBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("title", "STORE Camera") .addFormDataPart("file1","file1_stream.jpg", RequestBody.create(MultipartBody.FORM, file1)) .build();
암호: infos
'Android' 카테고리의 다른 글
안드로이드 일정 초기화 (0) 2023.04.23 OkHttp 파일 전송(Multipart) (0) 2022.08.08 Android 권한 요청 하기 (0) 2022.08.08 usesCleartextTraffic (0) 2022.08.08 OkHttp 접속 전송 RestfulApi (0) 2022.08.08 File 선택 화면 (deprecated startActivityForResult) (0) 2022.08.07 File 선택 화면 (0) 2022.08.07 RxAndroid (0) 2022.08.05