imgbb-uploader
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "imgbb-uploader", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Lightweight module to upload images through Imgbb API.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,5 +11,5 @@ # imgbb-uploader | ||
## Use | ||
- I) [First get a free API key from imgbb](https://api.imgbb.com/)(estimated time ~1 minute) | ||
- I) [Get a free API key from imgbb](https://api.imgbb.com/) ( estimated time : ~1 minute ) | ||
- II) (facultative) [Put that key in an environment variable](https://www.npmjs.com/package/dotenv) | ||
- III) **imgbbUploader takes *exactly two* String arguments**; first your API key, then the absolute path of your image : | ||
- III) **imgbbUploader takes *exactly two* String arguments** : your API key, then the absolute path of your image : | ||
@@ -19,3 +19,3 @@ ``` | ||
imgbbUploader("your-imgbb-api-key-string", "home/absolute-path-to-your-image/image.png") | ||
imgbbUploader("your-imgbb-api-key-string", "home/absolute/path/to/your/image/image.png") | ||
.then(response => console.log(response)) | ||
@@ -25,3 +25,3 @@ .catch(error => console.log(error)) | ||
### Output example of `.then(response => console.log(response))` : | ||
## `.then(response => console.log(response))` output example : | ||
``` | ||
@@ -55,11 +55,11 @@ { | ||
This function returns a promise, this is why `console.log(imgbbUploader(myKey, myPath) // output : Promise { <pending> }` | ||
You access it in your `.then(res => res)` as shown above. | ||
This function returns a promise, this is why : | ||
`console.log(imgbbUploader(myKey, myPath)) // output : Promise { <pending> }` | ||
Your data is available in the `.then(response => response)` as shown above. | ||
## Learn more | ||
This module doesn't support array uploads and other fancy stuff. For heavy duty uploads, you'll probably have to work with [fs.readdir](https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback) and [forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) methods. | ||
This module doesn't support array uploads and other fancy stuff. For heavy duty uploads, you'll probably have to work with [fs.readdir](https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback) and [forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) methods ; in that case you may also be interested in [path](https://nodejs.org/api/path.html#path_path). | ||
In which case you may also be interested in [path](https://nodejs.org/api/path.html#path_path). For example, you can create a `baseDir.js` file wherever your images are: | ||
For example, you can create a `baseDir.js` file wherever it suits you: | ||
``` | ||
@@ -71,4 +71,5 @@ // baseDir.js | ||
``` | ||
Then you can require this file elsewhere, and use something like `path.join(myDirpath, "subfolder", "subsubfolder")` to cross directories programmatically. Once you're there you can `fs.readdir` and iterate `forEach` file of that directory, then do whatever you want. That is just a simple example, see `fs` documentation and Stack Overflow for more inspiration. | ||
Then you can require this file elsewhere, and use something like `path.join(myDirpath, "subfolder", "subsubfolder")` to dig into directories programmatically. Once you're there you can `fs.readdir` and iterate `forEach` file of that directory, then do whatever you want. | ||
That is just a simple example, see `fs` documentation and Stack Overflow for more inspiration. | ||
## Anyway, the module is ~20 lines long & totally unlicensed, so even the most junior Nodejs dev should be able to easily adapt it to its needs. | ||
### Anyway, this module is ~20 lines long & totally unlicensed, so even the most junior Nodejs dev should be able to easily adapt it to its needs. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5430
70