bytex-sdk 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bytex-sdk",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "description": "The official ByteX Cloud SDK for BYOC (Bring Your Own Cloud) infrastructure management.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -128,6 +128,24 @@ export class BytexCloud {
128
128
  }, 'Download');
129
129
  }
130
130
 
131
+ getStreamUrl(name) {
132
+ const streamName = name.endsWith('.btx') ? name : (name.endsWith('.stream.btx') ? name : `${name}.stream.btx`);
133
+ return `${this.workerUrl}?action=view&key=${this.apiKey}&file=${encodeURIComponent(streamName)}`;
134
+ }
135
+
136
+ async download(name) {
137
+ return this._execute(async () => {
138
+ this._requireKey();
139
+ const url = this.getStreamUrl(name);
140
+ const { data: { session } } = await this.supabase.auth.getSession();
141
+ const res = await fetch(url, {
142
+ headers: { 'Authorization': `Bearer ${session?.access_token || ''}` }
143
+ });
144
+ if (!res.ok) throw new Error(`Status ${res.status}`);
145
+ return await res.blob();
146
+ }, 'Download');
147
+ }
148
+
131
149
  async delete(name) {
132
150
  return this._execute(async () => {
133
151
  this._requireKey();