diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a1219e51..cb7d7f9cf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ # [2.4.0](https://github.com/Alfresco/alfresco-js-api/releases/tag/2.4.0) (??-??-2018) ## Features +[Update Content in UplaodAPI](https://issues.alfresco.com/jira/browse/ADF-2563) ## Fixes diff --git a/index.d.ts b/index.d.ts index d3c2872188..6c5261c902 100644 --- a/index.d.ts +++ b/index.d.ts @@ -507,7 +507,7 @@ declare namespace AlfrescoApi { export interface NodesApi { new(client: ApiClient): NodesApi; - addNode(nodeId: string, nodeBody: any, opts?: { autoRename?: boolean, include?: Array, fields?: Array }): Promise; + addNode(nodeId: string, nodeBody: any, opts?: { autoRename?: boolean, include?: Array, fields?: Array }, formParams?: any): Promise; copyNode(nodeId: string, copyBody: any, opts?: { include?: Array, fields?: Array }): Promise; @@ -557,7 +557,7 @@ declare namespace AlfrescoApi { updateFileContent(nodeId?: string, contentBody?: string, opts?: { majorVersion?: boolean, comment?: string, include?: Array, fields?: Array }): Promise; - updateNodeContent(nodeId?: string, contentBody?: string, opts?: any): Promise; + updateNodeContent(nodeId?: string, contentBody?: string, opts?: any, formParams: string): Promise; updateNode(nodeId?: string, nodeBody?: NodeBody, opts?: { include?: Array, fields?: Array }): Promise; } @@ -5270,7 +5270,8 @@ declare namespace AlfrescoApi { export interface UploadApi { new(config: AlfrescoApiConfig): UploadApi; - uploadFile(fileDefinition?: any, relativePath?: any, nodeId?: any, nodeBody?: any, opts?: any): any; + uploadFile(fileDefinition?: any, relativePath?: any, rootFolderId?: string, nodeBody?: any, opts?: any): any; + updateFile(fileDefinition?: any, relativePath?: any, nodeId?: string, nodeBody?: any, opts?: any): any; addNodeUpload(nodeId?: any, nodeBody?: any, opts?: any, formParams?: any): any; } diff --git a/src/alfresco-core-rest-api/src/api/NodesApi.js b/src/alfresco-core-rest-api/src/api/NodesApi.js index bc3af8e8ea..94745d2838 100644 --- a/src/alfresco-core-rest-api/src/api/NodesApi.js +++ b/src/alfresco-core-rest-api/src/api/NodesApi.js @@ -43,9 +43,10 @@ * @param {Boolean} opts.autoRename If true, then a name clash will cause an attempt to auto rename by finding a unique name using an integer suffix. * @param {string[]} opts.include Returns additional information about the node. The following optional fields can be requested:\n* path\n* isLink\n* allowableOperations\n * @param {string[]} opts.fields A list of field names.\n\nYou can use this parameter to restrict the fields\nreturned within a response if, for example, you want to save on overall bandwidth.\n\nThe list applies to a returned individual\nentity or entries within a collection.\n\nIf the API method also supports the **include**\nparameter, then the fields specified in the **include**\nparameter are returned in addition to those specified in the **fields** parameter.\n + * @param {Object.} formParams A map of form parameters and their values. * data is of type: {module:model/NodeEntry} */ - this.addNode = function(nodeId, nodeBody, opts) { + this.addNode = function(nodeId, nodeBody, opts, formParams) { opts = opts || {}; var postBody = nodeBody; @@ -70,8 +71,7 @@ }; var headerParams = { }; - var formParams = { - }; + formParams = formParams || {}; var authNames = ['basicAuth']; var contentTypes = ['application/json', 'multipart/form-data']; @@ -888,6 +888,7 @@ 'nodeId': nodeId }; var queryParams = { + 'name': opts['name'], 'majorVersion': opts['majorVersion'], 'comment': opts['comment'], 'include': this.apiClient.buildCollectionParam(opts['include'], 'csv'), @@ -931,6 +932,7 @@ var queryParams = { 'majorVersion': opts['majorVersion'], 'comment': opts['comment'], + 'name': opts['name'], 'include': this.apiClient.buildCollectionParam(opts['include'], 'csv'), 'fields': this.apiClient.buildCollectionParam(opts['fields'], 'csv') }; diff --git a/src/alfrescoUpload.js b/src/alfrescoUpload.js index f51ff6cfd3..7e84c5d9d8 100644 --- a/src/alfrescoUpload.js +++ b/src/alfrescoUpload.js @@ -10,8 +10,8 @@ class AlfrescoUpload extends AlfrescoCoreRestApi.NodesApi { Emitter.call(this); } - uploadFile(fileDefinition, relativePath, nodeId, nodeBody, opts) { - nodeId = nodeId || '-root-'; + uploadFile(fileDefinition, relativePath, rootFolderId, nodeBody, opts) { + rootFolderId = rootFolderId || '-root-'; opts = opts || {}; var nodeBodyRequired = { @@ -31,17 +31,24 @@ class AlfrescoUpload extends AlfrescoCoreRestApi.NodesApi { formParam = Object.assign(formParam, opts); - return this.addNodeUpload(nodeId, nodeBody, opts, formParam); + return this.addNodeUpload(rootFolderId, nodeBody, opts, formParam); + } + + updateFile(fileDefinition, relativePath, nodeId, nodeBody, opts) { + opts = opts || {}; + + return this.updateNodeContent(nodeId, nodeBody, opts); } /** * Create a node * - * @param {String} nodeId The identifier of a node. You can also use one of these well-known aliases: -my-\ -shared- -root-\n + * @param {String} rootFolderId The identifier of a node. You can also use one of these well-known aliases: -my-\ -shared- -root-\n * @param {module:model/NodeBody1} nodeBody The node information to create. * @param {Object} opts Optional parameters * @param {Object.} formParams A map of form parameters and their values. */ + //@deprecated in 2.4.0 use addNode in NodesApi addNodeUpload(nodeId, nodeBody, opts, formParams) { opts = opts || {}; var postBody = nodeBody;