https://github.com/idoshamun/node-slack-upload
Node module for uploading files to slack using multipart or string
https://github.com/idoshamun/node-slack-upload
files javascript nodejs slack upload
Last synced: over 1 year ago
JSON representation
Node module for uploading files to slack using multipart or string
- Host: GitHub
- URL: https://github.com/idoshamun/node-slack-upload
- Owner: idoshamun
- License: mit
- Created: 2015-04-04T09:56:10.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T04:21:32.000Z (over 3 years ago)
- Last Synced: 2024-10-14T14:34:04.533Z (over 1 year ago)
- Topics: files, javascript, nodejs, slack, upload
- Language: JavaScript
- Size: 464 KB
- Stars: 11
- Watchers: 5
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# node-slack-upload
> A node module for uploading files to slack using multipart or string
[Slack](https://slack.com/) is a messaging platform that is easy to integrate with.
This module should be useful for for uploading files to Slack!
## Install
node-slack-upload is available via npm:
```
npm install node-slack-upload
```
## Usage
Get your Slack api token from [here](https://api.slack.com/web).
```
var Slack = require('node-slack-upload');
var slack = new Slack(token);
```
To upload a file from the filesystem as a post
```
slack.uploadFile({
file: fs.createReadStream(path.join(__dirname, '..', 'README.md')),
filetype: 'post',
title: 'README',
initialComment: 'my comment',
channels: 'XXXXX'
}, function(err, data) {
if (err) {
console.error(err);
}
else {
console.log('Uploaded file details: ', data);
}
});
```
To upload a file from a string as a post
```
slack.uploadFile({
content: 'My file contents!',
filetype: 'post',
title: 'README',
initialComment: 'my comment',
channels: 'XXXXX'
}, function(err, data) {
if (err) {
console.error(err);
}
else {
console.log('Uploaded file details: ', data);
}
});
```
For more details please refer [https://api.slack.com/methods/files.upload](https://api.slack.com/methods/files.upload)