alfresco-js-api icon indicating copy to clipboard operation
alfresco-js-api copied to clipboard

Support custom content type on fileUpload

Open ponsoc opened this issue 3 years ago • 1 comments

Type of issue: (check with "[x]")

- [ ] New feature request
- [x ] Bug  
- [ ] Support request

Current behavior: use the uploadFile method and set the nodeType to a custom created content type. The new document/file will have the default cm:document as a content type

Expected behavior: the custom content type is used instead of the default one

Steps to reproduce the issue: Create a custom content type derived from cm:document in your test environment. Then use uploadFile and set the nodeType to the custom created one.

Node version (for build issues):

New feature request:

ponsoc avatar Apr 12 '22 13:04 ponsoc

You can use formData to post your custom content :

const result = await this.nodesApi.createNode(
    object.parentNodeId,
    {
        name: object.name,
        nodeType: object.nodeType,
    },
    { autoRename: false },
    {
        filedata: createReadStream(object.file.path),
        name: object.name,
        nodeType: object.nodeType,
    }
);

It's still an issue as nodeBodyCreate is ignored when createNode use multipart:form-data

rsaenen avatar Jun 08 '22 13:06 rsaenen

You can override nodeType via nodeBody param: https://github.com/Alfresco/alfresco-js-api/blob/a55266731bc31903e38a8ab9885c4739d884a2d3/src/api/content-custom-api/api/upload.api.ts#L33

DenysVuika avatar Jun 16 '23 10:06 DenysVuika