ajesuscode
ajesuscode
CCConvex Community
Created by ajesuscode on 1/19/2024 in #support-community
get a url with path to a file in an action
Thank you guys. For the moment I went with api call solution, where I temporary store a file like this:
const data = await req.formData();
const file: File = data.get("file") as unknown as File;
if (!file) {
return NextResponse.json({ success: false });
}
console.log("file", file);
const bytes = await file.arrayBuffer();
const buffer = Buffer.from(bytes);

const path = join("/", "tmp", file.name);
await writeFile(path, buffer);
console.log("path", path);
const data = await req.formData();
const file: File = data.get("file") as unknown as File;
if (!file) {
return NextResponse.json({ success: false });
}
console.log("file", file);
const bytes = await file.arrayBuffer();
const buffer = Buffer.from(bytes);

const path = join("/", "tmp", file.name);
await writeFile(path, buffer);
console.log("path", path);
And I have that path to send to Whishper. Will look into, how to do it fully with Convex
11 replies
CCConvex Community
Created by ajesuscode on 1/19/2024 in #support-community
get a url with path to a file in an action
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?
11 replies
CCConvex Community
Created by ajesuscode on 1/19/2024 in #support-community
get a url with path to a file in an action
OpenAIWhisperAudio accepts only Blob or exact path to file
11 replies
CCConvex Community
Created by ajesuscode on 1/19/2024 in #support-community
get a url with path to a file in an action
Biut it says that Convex doesnt support Blob type ((
11 replies
CCConvex Community
Created by ajesuscode on 1/19/2024 in #support-community
get a url with path to a file in an action
export const langchain = action({
args: { file: v.any() },
handler: async (_, args) => {

const loader = new OpenAIWhisperAudio(args.file);
console.log("loader", loader);
const docs = await loader.load();
const text = docs[0].pageContent;
return "done";

}
})
export const langchain = action({
args: { file: v.any() },
handler: async (_, args) => {

const loader = new OpenAIWhisperAudio(args.file);
console.log("loader", loader);
const docs = await loader.load();
const text = docs[0].pageContent;
return "done";

}
})
11 replies