Skip to content

Commit

Permalink
Add implementation using GET because the expected AWS region cannot…
Browse files Browse the repository at this point in the history
… be determined from the HEAD error message if using AWS4-HMAC-SHA256 with the wrong region specifier in the authentication header.

Former-commit-id: c66d5916779eb23d45166da7bd398348f283f288
  • Loading branch information
dkocher committed Nov 2, 2014
1 parent 8d460af commit 19e79f9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions source/ch/cyberduck/core/s3/S3FindFeature.java
Expand Up @@ -22,9 +22,12 @@
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathContainerService;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.exception.InteroperabilityException;
import ch.cyberduck.core.exception.NotfoundException;
import ch.cyberduck.core.features.Find;

import org.jets3t.service.ServiceException;
import org.jets3t.service.model.S3Object;

/**
* @version $Id$
Expand Down Expand Up @@ -76,6 +79,21 @@ public boolean find(final Path file) throws BackgroundException {
}
}
catch(ServiceException e) {
if(new ServiceExceptionMappingService().map(e) instanceof InteroperabilityException) {
// Fallback to GET if HEAD fails with 400 response
try {
final S3Object object = session.getClient().getObject(containerService.getContainer(file).getName(),
containerService.getKey(file), null, null, null, null, 0L, 0L);
list.add(file);
return true;
}
catch(ServiceException f) {
if(new ServiceExceptionMappingService().map(f) instanceof NotfoundException) {
list.attributes().addHidden(file);
return false;
}
}
}
throw new ServiceExceptionMappingService().map("Failure to read attributes of {0}", e, file);
}
}
Expand Down

0 comments on commit 19e79f9

Please sign in to comment.