@ardrive/turbo-sdk 1.27.0-alpha.4 → 1.27.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.
package/README.md CHANGED
@@ -567,32 +567,25 @@ const uploadResult = await turbo.upload({
567
567
  });
568
568
  ```
569
569
 
570
- #### `uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts, events })`
570
+ #### `uploadFile({ ...fileOrStreamFactoryOpts, signal, dataItemOpts, events })`
571
571
 
572
- Signs and uploads a raw file. The provided `fileStreamFactory` should produce a NEW file data stream each time it is invoked. The `fileSizeFactory` is a function that returns the size of the file. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request. `dataItemOpts` is an optional object that can be used to configure tags, target, and anchor for the data item upload.
572
+ Signs and uploads a raw file. There are two ways to provide the file to the SDK:
573
+
574
+ 1. Using a `file` parameter
575
+ 2. Using a `fileStreamFactory` and `fileSizeFactory`
576
+
577
+ ##### Using `file`
578
+
579
+ In Web with a file input:
573
580
 
574
581
  ```typescript
575
- const filePath = path.join(__dirname, './my-unsigned-file.txt');
576
- const fileSize = fs.stateSync(filePath).size;
582
+ const selectedFile = e.target.files[0];
577
583
  const uploadResult = await turbo.uploadFile({
578
- fileStreamFactory: () => fs.createReadStream(filePath),
579
- fileSizeFactory: () => fileSize,
584
+ file: selectedFile,
580
585
  dataItemOpts: {
581
- // optional
582
- tags: [
583
- {
584
- name: 'Content-Type',
585
- value: 'text/plain',
586
- },
587
- {
588
- name: 'My-Custom-Tag',
589
- value: 'my-custom-value',
590
- },
591
- ],
592
- // no timeout or AbortSignal provided
586
+ tags: [{ name: 'Content-Type', value: 'text/plain' }],
593
587
  },
594
588
  events: {
595
- // upload events
596
589
  onUploadProgress: ({ totalBytes, processedBytes }) => {
597
590
  console.log('Upload progress:', { totalBytes, processedBytes });
598
591
  },
@@ -602,11 +595,36 @@ const uploadResult = await turbo.uploadFile({
602
595
  onUploadSuccess: () => {
603
596
  console.log('Upload success!');
604
597
  },
605
- // add any other events you want to listen to (see `Events` section for more details)
606
598
  },
607
599
  });
608
600
  ```
609
601
 
602
+ In NodeJS with a file path:
603
+
604
+ ```typescript
605
+ const filePath = path.join(__dirname, './my-unsigned-file.txt');
606
+ const fileSize = fs.stateSync(filePath).size;
607
+ const uploadResult = await turbo.uploadFile({
608
+ file: filePath,
609
+ dataItemOpts: {
610
+ tags: [{ name: 'Content-Type', value: 'text/plain' }],
611
+ },
612
+ });
613
+ ```
614
+
615
+ ##### Using `fileStreamFactory` and `fileSizeFactory`
616
+
617
+ Note: The provided `fileStreamFactory` should produce a NEW file data stream each time it is invoked. The `fileSizeFactory` is a function that returns the size of the file. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request. `dataItemOpts` is an optional object that can be used to configure tags, target, and anchor for the data item upload.
618
+
619
+ ```typescript
620
+ const filePath = path.join(__dirname, './my-unsigned-file.txt');
621
+ const fileSize = fs.stateSync(filePath).size;
622
+ const uploadResult = await turbo.uploadFile({
623
+ fileStreamFactory: () => fs.createReadStream(filePath),
624
+ fileSizeFactory: () => fileSize,
625
+ });
626
+ ```
627
+
610
628
  #### `uploadFolder({ folderPath, files, dataItemOpts, signal, maxConcurrentUploads, throwOnFailure, manifestOptions })`
611
629
 
612
630
  Signs and uploads a folder of files. For NodeJS, the `folderPath` of the folder to upload is required. For the browser, an array of `files` is required. The `dataItemOpts` is an optional object that can be used to configure tags, target, and anchor for the data item upload. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request. The `maxConcurrentUploads` is an optional number that can be used to limit the number of concurrent uploads. The `throwOnFailure` is an optional boolean that can be used to throw an error if any upload fails. The `manifestOptions` is an optional object that can be used to configure the manifest file, including a custom index file, fallback file, or whether to disable manifests altogether. Manifests are enabled by default.
@@ -314072,7 +314072,7 @@ var import_winston = __toESM(require_winston(), 1);
314072
314072
  init_dirname();
314073
314073
  init_buffer2();
314074
314074
  init_process2();
314075
- var version16 = "1.27.0-alpha.3";
314075
+ var version16 = "1.27.0-alpha.4";
314076
314076
 
314077
314077
  // src/common/logger.ts
314078
314078
  var TurboWinstonLogger = class _TurboWinstonLogger {
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '1.27.0-alpha.4';
20
+ exports.version = '1.27.0';
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '1.27.0-alpha.4';
17
+ export const version = '1.27.0';
@@ -13,5 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "1.27.0-alpha.3";
16
+ export declare const version = "1.27.0-alpha.4";
17
17
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.27.0-alpha.4",
3
+ "version": "1.27.0",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",