要上传图片到Autodesk的照片场景中可能会遇到上传失败的问题。此时可以根据以下步骤解决问题:
以下是上传图片的代码示例:
// Upload image to Photo Scene
const { photoScene } = require('forge-apis');
let oauth = forge.oauth;
let token = await oauth2TwoLegged.authenticate();
let photoSceneApi = new photoScene.PhotoSceneApi();
photoSceneApi.apiClient.basePath = forge.ApiUrl;
// Set Photo Scene ID
let photoSceneId = 'PHOTOSCENE_ID';
let buffer = fs.readFileSync('image.jpg');
let data = buffer.toString('base64');
// Upload image
let result = await photoSceneApi.uploadPhotoAsync(photoSceneId, {
data,
size: buffer.length,
filename: 'image.jpg'
}, oauth, token);