Alcumus / react-doc-viewer

Apache License 2.0
207 stars 101 forks source link

Could not open file using S3 signed URL #123

Open saravananpolyglot opened 1 year ago

saravananpolyglot commented 1 year ago

I have tried to open a pdf file from AWS S3 using S3 signed URL with GET but its not working as doc-viewer creates HEAD request to S3 endpoint.

Even I configured S3 CORS settings.

ContentView.propTypes = {
  fileUrl: PropTypes.string,
};
export default function ContentView({ fileUrl }) {
  const docs = [{ uri: fileUrl }];
  return fileUrl !== undefined && fileUrl !== null ? (
    <DocViewer pluginRenderers={DocViewerRenderers} documents={docs} style={{ height: 1000 }} />
  ) : (
    <p>Loading...</p>
  );
}
yaminibandi commented 1 year ago

Can you try by adding prefetch method like below:

<DocViewer documents={[{ uri: s3URL! }]} prefetchMethod="GET" ...

shrinathaithal commented 1 year ago

Agreed, this does not work with S3. How does one work with this?

luap2703 commented 1 year ago

Is there a fix for this???

OlajideOgun commented 1 year ago

any fix for this please?

evertoont commented 12 months ago

Try adding the fileType in your docs list object

For example: const docs = [{ uri: fileUrl, fileType: 'pdf }];

pkatul commented 9 months ago

Make sure that your s3 bucket cors permission is allowed from localhost

Check here https://repost.aws/knowledge-center/s3-configure-cors