shogun-relay-sdk 1.2.5 → 1.2.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.
- package/dist/modules/ipfs.js +9 -4
- package/package.json +1 -1
package/dist/modules/ipfs.js
CHANGED
|
@@ -66,12 +66,17 @@ class IpfsModule {
|
|
|
66
66
|
* @returns Promise with file content as Buffer
|
|
67
67
|
*/
|
|
68
68
|
async catFromDirectory(directoryCid, filePath) {
|
|
69
|
+
// IPFS API supports paths like CID/path/to/file
|
|
70
|
+
// We need to encode the CID but keep slashes for path navigation
|
|
71
|
+
// Format: /api/v0/cat?arg=QmDirectory/index.html
|
|
69
72
|
const fullPath = `${directoryCid}/${filePath}`;
|
|
70
|
-
|
|
73
|
+
// Encode only the CID part, keep slashes for navigation
|
|
74
|
+
const encodedPath = fullPath.includes('/')
|
|
75
|
+
? `${encodeURIComponent(directoryCid)}/${filePath.split('/').map(p => encodeURIComponent(p)).join('/')}`
|
|
76
|
+
: encodeURIComponent(fullPath);
|
|
77
|
+
return this.client.post(`/api/v1/ipfs/api/v0/cat?arg=${encodedPath}`, null, {
|
|
71
78
|
responseType: "arraybuffer",
|
|
72
|
-
|
|
73
|
-
"Content-Length": "0",
|
|
74
|
-
},
|
|
79
|
+
// Don't set Content-Length header - browser will block it
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
async pinAdd(cid) {
|
package/package.json
CHANGED