@@ -202,7 +202,7 @@ public InputStream newInputStream(Path path, OpenOption... options)
202
202
S3Path s3Path = (S3Path ) path ;
203
203
204
204
Preconditions .checkArgument (!s3Path .getKey ().equals ("" ),
205
- "cannot create InputStream for root directory: %s" , s3Path );
205
+ "cannot create InputStream for root directory: %s" , FilesEx . toUriString ( s3Path ) );
206
206
207
207
InputStream result ;
208
208
try {
@@ -213,13 +213,13 @@ public InputStream newInputStream(Path path, OpenOption... options)
213
213
.getObjectContent ();
214
214
215
215
if (result == null )
216
- throw new IOException (String .format ("The specified path is a directory: %s" , path ));
216
+ throw new IOException (String .format ("The specified path is a directory: %s" , FilesEx . toUriString ( s3Path ) ));
217
217
}
218
218
catch (AmazonS3Exception e ) {
219
219
if (e .getStatusCode () == 404 )
220
220
throw new NoSuchFileException (path .toString ());
221
221
// otherwise throws a generic IO exception
222
- throw new IOException (String .format ("Cannot access file: %s" , path ),e );
222
+ throw new IOException (String .format ("Cannot access file: %s" , FilesEx . toUriString ( s3Path ) ),e );
223
223
}
224
224
225
225
return result ;
@@ -258,11 +258,11 @@ public OutputStream newOutputStream(final Path path, final OpenOption... options
258
258
if (!(create && truncateExisting )) {
259
259
if (exists (s3Path )) {
260
260
if (createNew || !truncateExisting ) {
261
- throw new FileAlreadyExistsException (path . toString ( ));
261
+ throw new FileAlreadyExistsException (FilesEx . toUriString ( s3Path ));
262
262
}
263
263
} else {
264
264
if (!createNew && !create ) {
265
- throw new NoSuchFileException (path . toString ( ));
265
+ throw new NoSuchFileException (FilesEx . toUriString ( s3Path ));
266
266
}
267
267
}
268
268
}
@@ -496,13 +496,13 @@ public void delete(Path path) throws IOException {
496
496
S3Path s3Path = (S3Path ) path ;
497
497
498
498
if (Files .notExists (path )){
499
- throw new NoSuchFileException ("the path: " + path + " does not exist" );
499
+ throw new NoSuchFileException ("the path: " + FilesEx . toUriString ( s3Path ) + " does not exist" );
500
500
}
501
501
502
502
if (Files .isDirectory (path )){
503
503
try (DirectoryStream <Path > stream = Files .newDirectoryStream (path )){
504
504
if (stream .iterator ().hasNext ()){
505
- throw new DirectoryNotEmptyException ("the path: " + path + " is a directory and is not empty" );
505
+ throw new DirectoryNotEmptyException ("the path: " + FilesEx . toUriString ( s3Path ) + " is a directory and is not empty" );
506
506
}
507
507
}
508
508
}
@@ -541,7 +541,7 @@ public void copy(Path source, Path target, CopyOption... options)
541
541
if (!actualOptions .contains (StandardCopyOption .REPLACE_EXISTING )) {
542
542
if (exists (s3Target )) {
543
543
throw new FileAlreadyExistsException (format (
544
- "target already exists: %s" , target ));
544
+ "target already exists: %s" , FilesEx . toUriString ( s3Target ) ));
545
545
}
546
546
}
547
547
0 commit comments