I have some buckets to which I have uploaded a few AutoCAD drawings. I have converted to using the directToS3 approach to uploading files, and I can see the URNs of those files in the OSS bucket. However, when I try to convert the file to SVF or SVF2, passing the bucketID and the URN to the file in the bucket, the files aren't translating to SVF and it just sort of fails silently.
[HttpPost]
[Route("oss/uploadObject")]
public async Task<dynamic> UploadObject([FromForm]UploadFile input)
{
// save the file on the server
var uploadFolder = Path.Combine(Environment.CurrentDirectory, "Uploads");
if (!Directory.Exists(uploadFolder))
Directory.CreateDirectory(uploadFolder);
var fileSavePath = Path.Combine(uploadFolder, Path.GetFileName(input.fileToUpload.FileName));
dynamic uploadedObj;
using (var stream = new FileStream(fileSavePath, FileMode.Create))
{
await input.fileToUpload.CopyToAsync(stream);
uploadedObj = await BinarytransferClient.UploadToBucket( input.bucketKey,
Path.GetFileName(input.fileToUpload.FileName),
stream);
}
// cleanup, don't leave the binary on the server
System.IO.File.Delete(fileSavePath);
return uploadedObj;
}
File upload is handled via the forge-DirectToS3/BinaryTransferClient found at this URL, with my only change being how the token is passed since I had my own library already. Querying the OSS buckets after upload shows the following result:
[
{
"id": "weuwb5gtwqzvqiykmpvhh8fj2zhslnfk-test1",
"text": "test1",
"type": "bucket",
"hasChildren": true,
"drawings": [
{
"id": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6d2V1d2I1Z3R3cXp2cWl5a21wdmhoOGZqMnpoc2xuZmstdGVzdDEvNjExNTEwLmR3Zw==",
"text": "611510.dwg",
"type": "drawing",
"hasChildren": false,
"drawings": null,
"project": null
}
],
"project": null
},
{
"id": "weuwb5gtwqzvqiykmpvhh8fj2zhslnfk-test2",
"text": "test2",
"type": "bucket",
"hasChildren": true,
"drawings": [
{
"id": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6d2V1d2I1Z3R3cXp2cWl5a21wdmhoOGZqMnpoc2xuZmstdGVzdDIvNjA1NzAyLmR3Zw==",
"text": "605702.dwg",
"type": "drawing",
"hasChildren": false,
"drawings": null,
"project": null
}
],
"project": null
},
{
"id": "weuwb5gtwqzvqiykmpvhh8fj2zhslnfk-test4",
"text": "test4",
"type": "bucket",
"hasChildren": true,
"drawings": [
{
"id": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6d2V1d2I1Z3R3cXp2cWl5a21wdmhoOGZqMnpoc2xuZmstdGVzdDQvODgxMTYuZHdn",
"text": "88116.dwg",
"type": "drawing",
"hasChildren": false,
"drawings": null,
"project": null
}
],
"project": null
},
{
"id": "weuwb5gtwqzvqiykmpvhh8fj2zhslnfk638009921667451964-test3",
"text": "weuwb5gtwqzvqiykmpvhh8fj2zhslnfk638009921667451964-test3",
"type": "bucket",
"hasChildren": true,
"drawings": [
{
"id": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6d2V1d2I1Z3R3cXp2cWl5a21wdmhoOGZqMnpoc2xuZms2MzgwMDk5MjE2Njc0NTE5NjQtdGVzdDMvNjExNTEwLmR3Zw==",
"text": "611510.dwg",
"type": "drawing",
"hasChildren": false,
"drawings": null,
"project": null
}
],
"project": null
}
]
Finally, the transform code:
[HttpPost]
[Route("modelderivative/TranslateObject")]
public async Task<dynamic> TranslateObject([FromBody] TranslateObjectModel objModel)
{
dynamic oauth = await OAuthController.GetInternalAsync();
// prepare the payload
List<JobPayloadItem> outputs = new List<JobPayloadItem>()
{
new JobPayloadItem(
JobPayloadItem.TypeEnum.Svf2,
new List<JobPayloadItem.ViewsEnum>()
{
JobPayloadItem.ViewsEnum._2d,
JobPayloadItem.ViewsEnum._3d
})
};
JobPayload job;
job = new JobPayload(new JobPayloadInput(objModel.objectName), new JobPayloadOutput(outputs));
// start the translation
DerivativesApi derivative = new DerivativesApi();
derivative.Configuration.AccessToken = oauth.access_token;
dynamic jobPosted = await derivative.TranslateAsync(job, true);
return jobPosted;
}
/// <summary>
/// Model for TranslateObject method
/// </summary>
public class TranslateObjectModel
{
public string bucketKey { get; set; }
public string objectName { get; set; }
}
Passing any of the bucketKey, objectID combinations above results in, well, nothing. I get success from the backend, but I have no actual derivative, or if I do I don't know what the URL is. What exactly am I missing? Maybe I need to make another call to get a different URN for the SVF from some other location/API call?