You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Readable}from"node:stream";// ...// This is a `ReadableStream<Uint8Array>`...constaudio=(awaitfetch("https://upload.wikimedia.org/wikipedia/commons/7/71/George_Gershwin_2.ogg")).body!;constresponse=awaitclient.files.upload({channels: "<channel ID>",title: "Title",initial_comment: "Comment",// ...which I adapt into a Node.js `Readable` herefile: Readable.from(audio),filename: "audio.ogg",filetype: "ogg",});
With this code, the API response is {"ok":false,"error":"no_file_data"}. I was expecting this to work since the files.upload JavaScript sample code, whose docs do similar, refer to something like the above as the legacy way to upload files. My use case is simple so I think I'm ok with a legacy way, as long as it works. Thanks!
Hi @spencerwilson, thanks for asking the question! Our team is working on the files.upload v2 method addition in this PR: #90 but it seems the changes may need some time until its release.
As a short-term solution, checking my code example mentioned at #89 may be helpful for you. The code uploads a text file but you should be able to upload audio file by adjusting some parts of it.
Thanks very much @seratch , I'll give that a try! Here's some misc other context that Slack folks might want to know:
My use of the Deno client was in the context of a "next-gen app". I'm inexperienced with Deno, but very experienced with TypeScript and Node.js.
files.upload in the Deno client worked fine when uploading a text file via content; it's just this binary file upload I couldn't figure out how to get working
Question
How does one use
files.upload
? I triedWith this code, the API response is
{"ok":false,"error":"no_file_data"}
. I was expecting this to work since the files.upload JavaScript sample code, whose docs do similar, refer to something like the above as the legacy way to upload files. My use case is simple so I think I'm ok with a legacy way, as long as it works. Thanks!Context
Environment
deno 1.40.5 (release, aarch64-apple-darwin)
v8 12.1.285.27
typescript 5.3.3
ProductName: macOS
ProductVersion: 14.2.1
BuildVersion: 23C71
Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
The text was updated successfully, but these errors were encountered: