dtable-sdk
Advanced tools
Comparing version 5.0.2-alpha4 to 5.0.2-alpha6
@@ -83,2 +83,11 @@ "use strict"; | ||
}, { | ||
key: "getCustomAssetUploadLink", | ||
value: function getCustomAssetUploadLink(parentDir) { | ||
var _this$config4 = this.config, | ||
server = _this$config4.server, | ||
dtableUuid = _this$config4.dtableUuid; | ||
var url = server + '/api/v2.1/dtable-custom-asset/' + dtableUuid + '/upload-link/?parent_dir=' + encodeURIComponent(parentDir); | ||
return this.req.get(url); | ||
} | ||
}, { | ||
key: "uploadImage", | ||
@@ -85,0 +94,0 @@ value: function uploadImage(uploadLink, formData) { |
@@ -28,2 +28,17 @@ "use strict"; | ||
_classCallCheck(this, DTable); | ||
_defineProperty(this, "saveImageToCustomFolder", function (imageBlob, path, callback) { | ||
_this.dtableWebAPI.getCustomAssetUploadLink(path).then(function (res) { | ||
var _res$data = res.data, | ||
upload_link = _res$data.upload_link, | ||
parent_path = _res$data.parent_path, | ||
relative_path = _res$data.relative_path; | ||
var formData = new _formData["default"](); | ||
formData.append('parent_dir', parent_path); | ||
formData.append('relative_path', relative_path); | ||
formData.append('file', imageBlob); | ||
_this.dtableWebAPI.uploadImage(upload_link + '?ret-json=1', formData, function (event) { | ||
callback && callback(event); | ||
}); | ||
}); | ||
}); | ||
_defineProperty(this, "addLink", function (linkId, tableId, otherTableId, rowId, otherRowId) { | ||
@@ -52,3 +67,3 @@ _this.dtableStore.addLink(linkId, tableId, otherTableId, rowId, otherRowId); | ||
var _init = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(config) { | ||
var res, _res$data, app_name, access_token, dtable_uuid, dtable_server, dtable_socket; | ||
var res, _res$data2, app_name, access_token, dtable_uuid, dtable_server, dtable_socket; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -65,3 +80,3 @@ while (1) { | ||
res = _context.sent; | ||
_res$data = res.data, app_name = _res$data.app_name, access_token = _res$data.access_token, dtable_uuid = _res$data.dtable_uuid, dtable_server = _res$data.dtable_server, dtable_socket = _res$data.dtable_socket; | ||
_res$data2 = res.data, app_name = _res$data2.app_name, access_token = _res$data2.access_token, dtable_uuid = _res$data2.dtable_uuid, dtable_server = _res$data2.dtable_server, dtable_socket = _res$data2.dtable_socket; | ||
this.config.appName = app_name; | ||
@@ -173,5 +188,2 @@ this.config.accessToken = access_token; | ||
} | ||
// 这里支持上传文件到某个路径 | ||
// 如果是自定义目录,应该也支持 | ||
}, { | ||
@@ -216,36 +228,3 @@ key: "uploadFile", | ||
} | ||
// | ||
}, { | ||
key: "uploadFileTest", | ||
value: function uploadFileTest(fileContent, callback) { | ||
var _this4 = this; | ||
this.dtableWebAPI.getFileUploadLink().then(function (res) { | ||
var uploadLink = res.data.upload_link + '?ret-json=1'; | ||
var parentPath = res.data.parent_path; | ||
var relativePath = 'files'; | ||
var formData = new _formData["default"](); | ||
formData.append('parent_dir', parentPath); | ||
formData.append('relative_path', relativePath); | ||
formData.append('file', fileContent); | ||
var headers = Object.assign(formData.getHeaders()); | ||
_axios["default"].post(uploadLink, formData, { | ||
headers: headers | ||
}).then(function (res) { | ||
// add file url | ||
var fileInfo = res.data[0]; | ||
var _this4$config = _this4.config, | ||
server = _this4$config.server, | ||
workspaceID = _this4$config.workspaceID; | ||
var url = server + '/workspace/' + workspaceID + parentPath + '/' + relativePath + '/' + encodeURIComponent(fileInfo.name); | ||
fileInfo.url = url; | ||
callback(false, fileInfo); | ||
})["catch"](function (err) { | ||
callback(err); | ||
}); | ||
})["catch"](function (err) { | ||
callback(err); | ||
}); | ||
} | ||
}, { | ||
key: "addTable", | ||
@@ -252,0 +231,0 @@ value: function addTable(tableName) { |
{ | ||
"name": "dtable-sdk", | ||
"version": "5.0.2-alpha4", | ||
"version": "5.0.2-alpha6", | ||
"description": "dtable sdk", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
47164
872