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

presignedUrl file path must already exist #88

Closed
purplecabbage opened this issue Feb 25, 2021 · 1 comment
Closed

presignedUrl file path must already exist #88

purplecabbage opened this issue Feb 25, 2021 · 1 comment

Comments

@purplecabbage
Copy link
Member

Expected Behaviour

it should be possible to get a presignedUrl with write permission for a file that has not yet been created.

Actual Behaviour

an error is thrown

Reproduce Scenario (including but not limited to)

const rwdPresignUrl = await files.generatePresignURL('dir_could_not_exist/file_does_not_exist_yet.txt', {
  expiryInSeconds: 3600, 
  permissions: 'rwd'
})

Workaround

write to the file before getting the url

await files.write('dir_could_not_exist/file_does_not_exist_yet.txt', '')
const rwdPresignUrl = await files.generatePresignURL('dir_could_not_exist/file_does_not_exist_yet.txt', {
  expiryInSeconds: 3600, 
  permissions: 'rwd' 
})
@meryllblanchet
Copy link
Contributor

Feedback from @sandeep-paliwal :

You should be able to generate presign URLs for non existent files with 'rwd' permission. To write you can just make a PUT call to the generated URL with required file data. I gave it a try and it works fine. Here is sample code:

const presignUrl = await files.generatePresignURL('non-existent-folder/non-existent-file1.txt', { expiryInSeconds: 3600,
    permissions: 'rwd'}) 

Now use this URL to write to the file, here is sample CURL for writing plain text data:

curl --location --request PUT '<presign URL>' \
--header 'Content-Type: text/plain' \
--data-raw 'Test file write for non existent file and folder'

Does that solve the issue?

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

No branches or pull requests

2 participants