Skip to content

Commit

Permalink
CB-6011 fix read from s3
Browse files Browse the repository at this point in the history
  • Loading branch information
yagudin10 committed Dec 4, 2024
1 parent 0b5af36 commit ef78f5a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import org.jkiss.dbeaver.model.navigator.fs.DBNFileSystems;
import org.jkiss.dbeaver.model.navigator.fs.DBNPathBase;
import org.jkiss.dbeaver.registry.fs.FileSystemProviderRegistry;
import org.jkiss.utils.IOUtils;

import java.nio.charset.StandardCharsets;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.MessageFormat;
Expand Down Expand Up @@ -128,8 +130,10 @@ public String readFileContent(@NotNull WebSession webSession, @NotNull String no
throws DBWebException {

Check warning on line 130 in server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 'throws' has incorrect indentation level 8, expected level should be 12. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java:130:9: warning: 'throws' has incorrect indentation level 8, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
try {
Path filePath = FSUtils.getPathFromNode(webSession, nodePath);
var data = Files.readAllBytes(filePath);
return new String(data, StandardCharsets.UTF_8);
// Files.readAllBytes doesn't work for s3 if user doesn't have PutObject permission (need for S3SeekableByteChannel#seek)
try (Reader reader = new InputStreamReader(Files.newInputStream(filePath))) {
return IOUtils.readToString(reader);
}
} catch (Exception e) {
throw new DBWebException("Failed to read file content: " + e.getMessage(), e);
}
Expand Down

0 comments on commit ef78f5a

Please sign in to comment.