forked from kaimallea/node-imgur
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(example): adds example code for the browser and cleans up the com…
…pilation configuration
- Loading branch information
Showing
7 changed files
with
75 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const env = { | ||
"CLIENT_ID": "YOUR-CLIENT-ID", | ||
"ACCESS_TOKEN": "YOUR-ACCESS-TOKEN", | ||
"ALBUM": "YOUR-ALBUM" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<html> | ||
|
||
<head> | ||
|
||
<meta charset="utf-8"> | ||
<meta name="referrer" content="no-referrer" /> | ||
<meta type="title" content="Imgur API test"> | ||
<title>Imgur API test</title> | ||
<script src="../dist/imgur.js"></script> | ||
<script src="env.js"></script> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<img id="image" src="small.jpg"> | ||
<video id="video" src="small.mp4" controls> | ||
|
||
<script defer> | ||
const init = () => { | ||
function getImageStream(img) { | ||
const canvas = document.createElement("canvas"); | ||
canvas.width = canvas.height = 100; | ||
const ctx = canvas.getContext("2d"); | ||
ctx.drawImage(img, 0, 0) | ||
return canvas.toDataURL(); | ||
} | ||
|
||
const album = env.ALBUM; | ||
const client = new imgur({ | ||
accessToken: env.ACCESS_TOKEN, | ||
clientId: env.CLIENT_ID, | ||
}); | ||
|
||
const image = document.getElementById('image') | ||
const imageStream = getImageStream(image) | ||
client.upload({ album, image: imageStream, type: 'stream' }).then(console.log); | ||
|
||
const video = document.getElementById('video') | ||
const videoStream = getImageStream(video) | ||
client.upload({ album, image: videoStream, type: 'stream' }).then(console.log); | ||
} | ||
init() | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters