pinme 2.0.2-beta.5 → 2.0.2-beta.6

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/dist/index.js +23 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1523,7 +1523,7 @@ var import_chalk25 = __toESM(require("chalk"));
1523
1523
  var import_figlet5 = __toESM(require("figlet"));
1524
1524
 
1525
1525
  // package.json
1526
- var version = "2.0.2-beta.5";
1526
+ var version = "2.0.2-beta.6";
1527
1527
 
1528
1528
  // bin/upload.ts
1529
1529
  var import_path6 = __toESM(require("path"));
@@ -5577,24 +5577,35 @@ async function compressDirectory(sourcePath) {
5577
5577
  }
5578
5578
  });
5579
5579
  }
5580
- async function initChunkSession(filePath, deviceId, isDirectory = false) {
5580
+ async function initChunkSession(filePath, deviceId, options = {}, isDirectory = false) {
5581
+ var _a2;
5581
5582
  const stats = import_fs_extra4.default.statSync(filePath);
5582
5583
  const fileName = import_path5.default.basename(filePath);
5583
5584
  const fileSize = stats.size;
5584
5585
  const md5 = await calculateMD5(filePath);
5585
5586
  try {
5587
+ const projectName = (_a2 = options.projectName) == null ? void 0 : _a2.trim();
5588
+ let authHeaders = {};
5589
+ const requestBody = {
5590
+ file_name: fileName,
5591
+ file_size: fileSize,
5592
+ md5,
5593
+ is_directory: isDirectory,
5594
+ uid: deviceId
5595
+ };
5596
+ if (projectName) {
5597
+ requestBody.project_name = projectName;
5598
+ authHeaders = getAuthHeaders();
5599
+ }
5586
5600
  const response = await axios_default.post(
5587
5601
  `${IPFS_API_URL}/chunk/init`,
5588
- {
5589
- file_name: fileName,
5590
- file_size: fileSize,
5591
- md5,
5592
- is_directory: isDirectory,
5593
- uid: deviceId
5594
- },
5602
+ requestBody,
5595
5603
  {
5596
5604
  timeout: TIMEOUT,
5597
- headers: { "Content-Type": "application/json" }
5605
+ headers: {
5606
+ "Content-Type": "application/json",
5607
+ ...authHeaders
5608
+ }
5598
5609
  }
5599
5610
  );
5600
5611
  const { code, msg, data } = response.data;
@@ -5851,7 +5862,7 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
5851
5862
  const compressedPath = await compressDirectory(directoryPath);
5852
5863
  progressBar.completeStep();
5853
5864
  progressBar.startStep(1, "Initializing session");
5854
- const sessionInfo = await initChunkSession(compressedPath, deviceId, true);
5865
+ const sessionInfo = await initChunkSession(compressedPath, deviceId, options, true);
5855
5866
  progressBar.completeStep();
5856
5867
  progressBar.startStep(2, "Chunk upload");
5857
5868
  await uploadFileChunks(
@@ -5910,7 +5921,7 @@ async function uploadFileInChunks(filePath, deviceId, options = {}) {
5910
5921
  const progressBar = new StepProgressBar(fileName, false);
5911
5922
  try {
5912
5923
  progressBar.startStep(0, "Initializing session");
5913
- const sessionInfo = await initChunkSession(filePath, deviceId, false);
5924
+ const sessionInfo = await initChunkSession(filePath, deviceId, options, false);
5914
5925
  progressBar.completeStep();
5915
5926
  progressBar.startStep(1, "Chunk upload");
5916
5927
  await uploadFileChunks(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinme",
3
- "version": "2.0.2-beta.5",
3
+ "version": "2.0.2-beta.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },