epubjs-rn icon indicating copy to clipboard operation
epubjs-rn copied to clipboard

Not able to read epub as signed url from s3

Open hsparihar-systango opened this issue 5 years ago • 5 comments

While I am using any open s3 url I am able to load and read epub like https://s3.amazonaws.com/epubjs/books/moby-dick.epub but when I use signed s3 URL getting an error while starting streamer i.e. this.streamer.start
{ [Error: failed to open zip file] framesToPop: 1, code: 'unzip_error', domain: 'SSZipArchiveErrorDomain', userInfo: { NSLocalizedDescription: 'failed to open zip file' },

signed URL like https://mydomain.s3.uss-east-235.amazonaws.com/epub/test.epub?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA5Q2POCDOH2PPQPV4%2F20190925%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20190925T104823Z&X-Amz-Expires=80000&X-Amz-Signature=e5b4cea0fc418edd432a3f02f0a8d2e20&X-Amz-SignedHeaders=host

port started successfully GCDWebServer started on port 8899 and reachable at http://localhost:8899/

Any help will be much appreciated.

hsparihar-systango avatar Sep 26 '19 11:09 hsparihar-systango

I am facing issues with the s3 signed URL. But I am getting 403 on /META-INF/container.xml

@hsparihar-systango have you find any solution for this?

goyalsushant avatar Oct 14 '19 12:10 goyalsushant

@goyalsushant in this module filename code is very sensitive for name and in signed URLs name is too long as it has additional pieces of information as well, so try with this code in Streamer.js file, replace existing code with this one

{ key: "filename", value: function filename(bookUrl) { var uri = new Uri(bookUrl); let finalFileName; if(uri.filename.indexOf("?") > -1) { finalFileName = uri.filename.split("?")[0].replace(".epub", ""); } else { finalFileName = uri.filename.replace(".epub", ""); } return finalFileName; } },

hsparihar-systango avatar Oct 14 '19 12:10 hsparihar-systango

@hsparihar-systango can you please mention the path for the file ?

goyalsushant avatar Oct 15 '19 06:10 goyalsushant

@goyalsushant file path /node_modules/epubjs-rn/components/Streamer.js

hsparihar-systango avatar Dec 16 '19 10:12 hsparihar-systango

@hsparihar-systango I faced a similar problem but in my case, it was the problem with bucket permission. Please check you S3 bucket policy, IAM (Role + policy).

@goyalsushant After solving the above problem, I faced the exact exception you got. For me, it is angular-epub-viewer which reads the CDN's presigned URL. Solution: The name of the file(uploaded on S3) must end with ".epub" extension.

mananshah88 avatar Jan 14 '20 06:01 mananshah88