Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileName instead of complete Absolute path #523

Open
voodo12345 opened this issue Aug 4, 2020 · 0 comments
Open

FileName instead of complete Absolute path #523

voodo12345 opened this issue Aug 4, 2020 · 0 comments

Comments

@voodo12345
Copy link

I was using your library in my application and noticed that in multipart file upload, in filename complete path of file is coming in request for eg. in case of external storage something like /storage/0/emulated/filename.jpg and in case of internal storage /data/data/com.test.test/files/filename.jpg.

Ideally only the file name should come in request not the absolute path.

I think, it can be fixed by modifying in this particular code snippet, by extracting actual file name in fileName variable.

for (HashMap.Entry<String, List> entry : mMultiPartFileMap.entrySet()) {
List fileBodies = entry.getValue();
for (MultipartFileBody fileBody : fileBodies) {
String fileName = fileBody.file.getName();
MediaType mediaType;
if (fileBody.contentType != null) {
mediaType = MediaType.parse(fileBody.contentType);
} else {
mediaType = MediaType.parse(Utils.getMimeType(fileName));
}
RequestBody requestBody = RequestBody.create(mediaType, fileBody.file);
builder.addPart(Headers.of("Content-Disposition",
"form-data; name="" + entry.getKey() + ""; filename="" + fileName + """),
requestBody);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant