-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaliyun-oss-client.js
45 lines (37 loc) · 1.39 KB
/
aliyun-oss-client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*\
title: $:/plugins/FSpark/file-uploads-Aliyun-OSS/aliyun-oss-client.js
type: application/javascript
module-type: library
Get a single OSS instance.
\*/
(function () {
/*jslint node: false, browser: true */
/*global $tw: false */
"use strict";
var AliyunOSS = require("$:/plugins/FSpark/file-uploads-Aliyun-OSS/aliyun-oss-sdk.min.js");
exports.OSSInit = OSSClient;
function OSSClient() {
// if (!exports.AliyunOSSInfo || JSON.stringify(exports.AliyunOSSInfo) !== JSON.stringify(AliyunOSSInfo)) {
if (!exports.AliyunOSSInfo || !exports.client) {
var bucket = $tw.wiki.getTiddlerText("$:/AliyunOSS/Bucket"),
region = $tw.wiki.getTiddlerText("$:/AliyunOSS/Region"),
accessKeyId = $tw.wiki.getTiddlerText("$:/AliyunOSS/AccessKeyId"),
accessKeySecret = $tw.utils.getPassword("AliyunOSS-KeySecret");
if (!accessKeyId || !bucket || !region || !accessKeySecret) {
if (!exports.logger)
exports.logger = new $tw.utils.Logger("oss-uploader");
exports.logger.alert("AliyunOSS bucket details are not properly configured. Cannot upload files.");
return null;
}
var AliyunOSSInfo = {
accessKeyId: accessKeyId.trim(),
region: region.trim(),
bucket: bucket.trim().split("/").pop(),
accessKeySecret: accessKeySecret.trim()
}
exports.AliyunOSSInfo = AliyunOSSInfo;
exports.client = new AliyunOSS(AliyunOSSInfo)
}
}
//module.exports = OSSClient;
})();