autodesk-forgeautodeskautodesk-data-management

File Upload Issues in Autodesk Platform Services


I am trying to upload a file (a .png as a test) directly to the ACC cloud using the Object API. With the following code I get a 200 response back. But I cannot see the uploaded file in the ACC folder. What am I doing wrong?

const { bucketKey, objectKey } = req.body;
const fileContent = await fs.readFile("file.png");
const response = await new APS.ObjectsApi().uploadResources(
  bucketKey,
  [
    {
      objectKey: objectKey,
      data: fileContent,
    },
  ],
  {},
  internalAuthClient,
  req.internalOAuthToken
);

Also, the API documentation seems a bit ambiguous. According to the Object API, there is a method called uploadObject, but looking at the Source Code, this method is deprecated. On the other hand, the uploadResources method is not mentioned in the Object API documentation. So I am not sure if I am using the method correctly.


Solution

  • To update a file to ACC Docs, there are some additional steps to create a new version to get it listed in the folder. Here are the steps you can refer https://aps.autodesk.com/en/docs/data/v2/tutorials/upload-file/ .

    About the upload code, you can reference https://github.com/autodesk-platform-services/aps-create-revit-family/blob/master/routes/da4revit.js#L233 to post an item or a new version.