Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated presigned URLs do not work in the browser #87

Closed
tmathern opened this issue Feb 17, 2021 · 4 comments
Closed

Generated presigned URLs do not work in the browser #87

tmathern opened this issue Feb 17, 2021 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@tmathern
Copy link
Member

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 #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 #59 also, I think).

Steps to Reproduce

Run the code from the previous point.

Platform and Version

  • Node 12.16.0

Logs taken while reproducing problem

None.

@meryllblanchet meryllblanchet added the question Further information is requested label Feb 18, 2021
@meryllblanchet
Copy link
Contributor

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

@sandeep-paliwal
Copy link
Contributor

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
Copy link
Contributor

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

@tmathern
Copy link
Member Author

@meryllblanchet It helped. I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants