Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ipfs-images-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ipfs-images
ipfs-images-components
Commits
0f517e4c
Commit
0f517e4c
authored
Apr 13, 2017
by
Vladislav Bashkirev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce pin and unpin methods
Wrap IPFS pin.add and pin.rm to allow access for other classes.
parent
a6f3bac8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
ipfs.js
components/ipfs.js
+21
-0
No files found.
components/ipfs.js
View file @
0f517e4c
...
...
@@ -20,6 +20,16 @@ class Ipfs {
}
/**
* Stores an IPFS object from a given path locally to disk.
* @param {String} hash IPFS hash.
* @return {Promise} Pinned object.
*/
pin
(
hash
)
{
logging
.
verbose
(
`Pinning object
${
hash
}
to local storage`
);
return
this
.
ipfs
.
pin
.
add
(
hash
);
}
/**
* Serves attachment to the client.
* @param {String} hash IPFS hash.
* @return {Promise} Readable Stream of attachment.
...
...
@@ -36,6 +46,17 @@ class Ipfs {
}
/**
* Removes the pin from the given object allowing it to be garbage
* collected if needed.
* @param {String} hash IPFS hash.
* @return {Promise} Unpinned object.
*/
unpin
(
hash
)
{
logging
.
verbose
(
`Unpinning object
${
hash
}
from local storage`
);
return
this
.
ipfs
.
pin
.
rm
(
hash
);
}
/**
* Uploads attachment to IPFS.
* @param {File} file Multipart/form-data file.
* @return {Promise} IPFS hash of uploaded attachment.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment