get a url with path to a file in an action
I am wondering how can i get a file path, so I can provide it to OpenAiWhishperer. Cuz passing an url throws me an error: Uncaught (in promise) Error: [CONVEX A(actions:langchain)] Uncaught Error: ENOENT: no such file or directory.
But when i click on url the image is downloding.
So I assume there should be a valid path to the image, that I can provide to Whisher.?
8 Replies
Hey @ajesuscode, can you provide a snippet of your code? It’s unclear what you’re trying to achieve.
Biut it says that Convex doesnt support Blob type ((
OpenAIWhisperAudio accepts only Blob or exact path to file
You'll need to use an action (https://docs.convex.dev/functions/actions), and load the file before passing it to OpenAIWhisperAudio.
You could:
- Fetch the file from somewhere using
fetch
and directly pass it to OpenAIWhisperAudio
- Accepting the blob in an HTTP Action (https://docs.convex.dev/functions/http-actions) (like here, you don't have to store it: https://docs.convex.dev/file-storage/upload-files#defining-the-upload-http-action )
- Use Convex file storage https://docs.convex.dev/file-storage/store-files
File blobs are indeed not supported as arguments to queries/mutations/actions.HTTP Actions | Convex Developer Hub
HTTP actions allow you to build an HTTP API right in Convex!
Storing Generated Files | Convex Developer Hub
Files can be uploaded to Convex from a client and stored directly, see
Uploading and Storing Files | Convex Developer Hub
Files can be uploaded by your users and stored in Convex.
Thanx for such detailed approach. It helpful in some cases, but I am more interested in actual file path, with file extenssion, like https://blablablaurl.com/filename_whatever.mp3 or mov or whatever extenssion is. Is it possible to have from Convex Storage?
You can write an HTTP Action that serves at such an URL: https://docs.convex.dev/file-storage/serve-files#serving-files-from-http-actions
You'll have to store the file name yourself in a Convex table, Convex Storage doesn't include it.
Serving Files | Convex Developer Hub
Files stored in Convex can be served to your users by generating a URL pointing
Or you can get the url from something stored in file storage:
await ctx.storage.getUrl(storageId)
(that URL will not have a file name with extension, but it will be a URL)
Thank you guys. For the moment I went with api call solution, where I temporary store a file like this:
And I have that path to send to Whishper.
Will look into, how to do it fully with Convex