Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
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
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
b59a9361
Commit
b59a9361
authored
Dec 24, 2019
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
bf627bc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
taskexecutor/app/base/utils/ossClient.js
+47
-0
No files found.
taskexecutor/app/base/utils/ossClient.js
0 → 100644
View file @
b59a9361
var
co
=
require
(
'co'
);
var
OSS
=
require
(
'ali-oss'
);
class
OSSClient
{
constructor
(){
this
.
client
=
new
OSS
({
endpoint
:
'https://oss-cn-beijing.aliyuncs.com'
,
accessKeyId
:
'LTAIyAUK8AD04P5S'
,
accessKeySecret
:
'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla'
});
this
.
client
.
useBucket
(
'gsb-zc'
);
}
async
downfile
(
key
){
var
me
=
this
;
var
result
=
await
co
(
function
*
()
{
var
result
=
yield
me
.
client
.
get
(
key
,
'/tmp/'
+
key
);
return
result
;
});
return
result
;
}
async
upfile
(
key
,
filepath
){
var
me
=
this
;
var
result
=
await
co
(
function
*
()
{
var
result
=
yield
me
.
client
.
put
(
key
,
filepath
);
return
result
;
})
return
result
;
}
async
putBuffer
(
key
,
buf
)
{
try
{
var
result
=
await
this
.
client
.
put
(
key
,
buf
);
console
.
log
(
result
);
return
result
}
catch
(
e
)
{
console
.
log
(
e
);
return
null
}
}
}
module
.
exports
=
OSSClient
;
// var oss=new OSSClient();
// var key="netsharp_QSzjD4HdKdTmRR6b5486pEA3AbsW8Pr8.jpg"
// oss.upfile(key,"/usr/devws/OMC/igirl-api/r3.jpg").then(function(result){
// console.log(result);
// });
// oss.downfile(key).then(function(result){
// console.log(result);
// });
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