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

getItemRaw() on PNG returns null #222

Closed
bart opened this issue May 17, 2023 · 6 comments · Fixed by #232
Closed

getItemRaw() on PNG returns null #222

bart opened this issue May 17, 2023 · 6 comments · Fixed by #232

Comments

@bart
Copy link

bart commented May 17, 2023

Environment

Node: 18.6.0
NPM: 8.19.2
unjs/unstorage: 1.6.0

Reproduction

Hopefully description is enough here

Describe the bug

On a brand new Nuxt 3 project I'm using the Nitro Custom Server Assets feature to access files from public folder on server-side API. To access one of the files I'm using the getItemRaw() method expecting the buffer as a result but getting null instead.

// Nitro config
serverAssets: [{
  baseName: 'public',
  dir: '../public'
}]

// Server-side API
const imageBuffer = await useStorage('assets:public').getItemRaw('x.png')
console.log(imageBuffer) // <--- returns null

Additional context

Looks like driver is memory when used with Nuxt. Could this be an issue?
I also described the problem here: nitrojs/nitro#1230

Logs

No response

@maou-shonen
Copy link
Contributor

maou-shonen commented May 21, 2023

#142
I haven't looked into it further, but I came across this.

(I only tested the fs and memory drivers)

await useStorage('assets:public').getItemRaw('x.png') // not work, get null
await useStorage().getItemRaw('assets:public:x.png') // work

@bart
Copy link
Author

bart commented May 21, 2023

Thanks a lot @maou-shonen
That really solved the issue but seems to be an issue, anyway right? What do you think?

Cheers!

@bart
Copy link
Author

bart commented May 23, 2023

@maou-shonen It's weird. It works in dev but when you build it and run npm run preview it returns file contents instead of buffer. I don't understand why.

@maou-shonen
Copy link
Contributor

@maou-shonen It's weird. It works in dev but when you build it and run npm run preview it returns file contents instead of buffer. I don't understand why.

Maybe you can provide a minimal reproduction?

@bart
Copy link
Author

bart commented May 23, 2023

I found another solution. Using base64 images now so that I don't that extra loop with useStorage(). Might be more a Nuxt issue and not so much an Unstorage one, right?

@maou-shonen
Copy link
Contributor

Hmm... I'm not sure.
In my use case, I only use redis and custom driver,
and I haven't encountered the issue you described in my testing environment.

@pi0 pi0 closed this as completed May 24, 2023
@pi0 pi0 reopened this May 24, 2023
@pi0 pi0 closed this as completed in #232 May 24, 2023
pi0 pushed a commit that referenced this issue May 24, 2023
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

Successfully merging a pull request may close this issue.

3 participants