Toggle navigation
Toggle navigation
This project
Loading...
Sign in
은승우
/
LINEBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
은승우
2019-12-05 15:35:12 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dacbfc55f87244b790bd2a3a9bbe15fe9981c6e4
dacbfc55
1 parent
6b44afd2
Update app.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
app.js
app.js
View file @
dacbfc5
...
...
@@ -82,9 +82,20 @@ async function handleEvent(event) {
}
else
if
(
event
.
type
==
'message'
&&
event
.
message
.
type
==
'image'
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
fs
.
writeFileSync
(
'./photo/image.png'
,
event
.
message
.
image
)
client
.
getMessageContent
(
event
.
message
.
id
)
.
then
((
stream
)
=>
{
stream
.
on
(
'data'
,
(
chunk
)
=>
{
const
fs
=
require
(
'fs'
);
const
file
=
fs
.
createWriteStream
(
'./photo/image.jpeg'
);
for
(
let
i
=
0
;
i
<=
1
e6
;
i
++
)
{
file
.
write
(
chunk
);
}
file
.
end
();
});
});
var
cheerio
=
require
(
'cheerio'
);
var
file
=
fs
.
readFileSync
(
'./photo/image.png'
);
var
uriBase
=
'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr'
;
var
options
=
{
uri
:
uriBase
,
...
...
@@ -94,10 +105,10 @@ async function handleEvent(event) {
language
:
'en'
},
headers
:
{
'Content-Type'
:
'application/
octet-stream
'
,
'Content-Type'
:
'application/
json
'
,
'Ocp-Apim-Subscription-Key'
:
'979dc5d63344438fa4701c62feebb7dc'
},
body
:
f
ile
body
:
f
s
.
readFileSync
(
'./photo/image.jpeg'
)
};
request
.
post
(
options
,
function
(
error
,
response
,
body
)
{
...
...
Please
register
or
login
to post a comment