File Storage - file name rules? Can't access files with spaces (even if i correctly convert them to valid URIs)

0 votes

Following filename works:

  • WKM.json

Following doesn't work:

  • German Volume Training - Phase 2.1.json

I even tried to create URI encoded filenames, this does not help...

I'm trying to download the file with:

URL url = new URL(uploadFile.getUrl());
URLConnection connection = url.openConnection(); 

connection.connect();

BufferedReader br = null;
InputStream input = new BufferedInputStream(url.openStream(), 8192);

The last line fails with a FileNotFoundException...

asked Feb 14, 2015 in App42 Cloud API-BaaS by mflisar85 (40 points)
reopened Feb 17, 2015 by mflisar85
Thanks for the feedback. You can any time convert this into URL object by passing String value in it.
that's what I do above and that's not correct... i'll post my solution that shows the "problem"...

1 Answer

0 votes

Here's the solution that works for me:

String string = uploadFile.getUrl();
int pos = string.lastIndexOf('/') + 1;
URI uri = new URI(string.substring(0, pos) + URLEncoder.encode(string.substring(pos), "utf-8"));

URL url = uri.toURL();
URLConnection connection = url.openConnection();
connection.connect();

BufferedReader br = null;
InputStream input = new BufferedInputStream(url.openStream(), 8192);

answered Feb 17, 2015 by mflisar85 (40 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...