adobe / aio-lib-files

An abstraction on top of cloud blob storage exposing a file system like API
https://www.adobe.io
Apache License 2.0
10 stars 14 forks source link

Generated presigned URLs do not work in the browser #87

Closed tmathern closed 3 years ago

tmathern commented 3 years ago

Expected Behaviour

Presigned URLs generated by the aio-lib-files library should be usable directly in the browser as is. If I used the library in a wrong way (see below), would there be a way to support this usage? (Which comes near to https://github.com/adobe/aio-lib-files/issues/59).

Actual Behaviour

Presigned URLs generated by the aio-lib-files library cannot be used. For instance when trying with the browser, I get this error:

<Error>
<Code>BlobNotFound</Code>
<Message>The specified blob does not exist. RequestId:92974b1e-d01e-0114-6272-05e910000000 Time:2021-02-17T21:21:06.1462572Z</Message>
</Error>

Reproduce Scenario (including but not limited to) & Sample Code that illustrates the problem

Run this piece of code. The generated URLs won't work:

        const filesLib = require('@adobe/aio-lib-files');

        // generate presigned-urls for input and output
        const files = await filesLib.init({
            azure:
            {
                storageAccount: process.env.AZURE_STORAGE_ACCOUNT,
                storageAccessKey: process.env.AZURE_STORAGE_KEY,
                containerName: process.env.AZURE_STORAGE_CONTAINER,
            }
        });

        const readUrl = await files.generatePresignURL("./test/files/newton.dn", 
            { 
                expiryInSeconds: 86400, 
                permissions: 'r'
            }
        );
        console.log(readUrl);

        const writeUrl = await files.generatePresignURL("./test/files/newton.dn", 
            { 
                expiryInSeconds: 86400, 
                permissions: 'rwd'
            }
        );
        console.log(writeUrl);

If I used the library in a wrong way, would there be a way to support this usage, so I can use aio-lib-files for all my needs? (Which comes near to https://github.com/adobe/aio-lib-files/issues/59 also, I think).

Steps to Reproduce

Run the code from the previous point.

Platform and Version

Logs taken while reproducing problem

None.

meryllblanchet commented 3 years ago

Hi @tmathern , let's ask @sandeep-paliwal and @moritzraho for more guidance.

sandeep-paliwal commented 3 years ago

Hi @tmathern , I guess the file is not present in the file storage for which the URLs are being generated. You will have to create the file using the write operation and then it can be shared using presign-URLs. Just add following line before generating the URL and see if this works for you. await files.write('./test/files/newton.dn', '<h1>Test file url issue</h1>')

meryllblanchet commented 3 years ago

Hi @tmathern ! Did @sandeep-paliwal 's answer help you solve your issue?

tmathern commented 3 years ago

@meryllblanchet It helped. I'll close this.