diff --git a/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java b/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java index 187184c780..d7e2959e5d 100644 --- a/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java +++ b/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java @@ -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; @@ -128,8 +130,10 @@ public String readFileContent(@NotNull WebSession webSession, @NotNull String no throws DBWebException { 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); }