0

I have created an OSS bucket and I'm trying to upload a file to it, but getting an error every time. Here is my bucket:

{
  "dictionary": {
    "bucketKey": "-removed my client id-------------test1",
    "bucketOwner": "-removed my client id------------",
    "createdDate": 1661180310185,
    "permissions": {
      "dictionary": {
        "0": {
          "dictionary": {
            "authId": "-removed my client id------------",
            "access": "full"
          },
          "count": 2
        }
      },
      "count": 1
    },
    "policyKey": "temporary"
  },
  "count": 5
}

When I try to upload a CAD file to the bucket, I get an error as shown below. I have created a few buckets with another app, and even gone so far as to remove my old app and create a new one. Same issue.

Autodesk.Forge.Client.ApiException: Error calling UploadObject: {"reason":"No write access"}
   at Autodesk.Forge.ObjectsApi.UploadObjectAsyncWithHttpInfo(String bucketKey, String objectName, Nullable`1 contentLength, Stream body, String contentDisposition, String ifMatch, String contentType)
   at Autodesk.Forge.ObjectsApi.UploadObjectAsync(String bucketKey, String objectName, Nullable`1 contentLength, Stream body, String contentDisposition, String ifMatch, String contentType)
   at PE_AutodeskForgeService.Controllers.OSSController.UploadObject(UploadFile input) in D:\Code\PE_AutodeskForgeService\PE_AutodeskForgeService\Controllers\OSSController.cs:line 127
   at lambda_method61(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS
=======
Accept: */*
Connection: keep-alive
Host: localhost:3000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.63
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryr5CxWcAi4docJmf4
Origin: http://localhost:3000
Referer: http://localhost:3000/swagger/index.html
Content-Length: 364166
sec-ch-ua: "Chromium";v="104", " Not A;Brand";v="99", "Microsoft Edge";v="104"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty

Pretty sure this isn't a Scope issue, as scope is set as shown below:

        public static async Task<dynamic> GetInternalAsync()
        {
            if (InternalToken == null || InternalToken.ExpiresAt < DateTime.UtcNow)
            {
                InternalToken = await Get2LeggedTokenAsync(new Scope[] { Scope.BucketCreate, Scope.BucketRead, Scope.BucketUpdate, Scope.BucketDelete, Scope.DataRead, Scope.DataWrite, Scope.DataCreate, Scope.CodeAll });
                InternalToken.ExpiresAt = DateTime.UtcNow.AddSeconds(InternalToken.expires_in);
            }

            return InternalToken;
        }
ShawnW.
  • 1,771
  • 1
  • 12
  • 12

1 Answers1

0

Please check two things:

  • that your code is generating the token for the same Forge Client ID that owns the bucket
  • that your Forge subscription is valid (if it's a trial, perhaps it has expired?)

And if none of the above helps, please share your Forge Client ID and the name of one of the problematic buckets with us via forge (dot) help (at) autodesk (dot) com.

Petr Broz
  • 8,891
  • 2
  • 15
  • 24
  • I found a github repo from JoaoMartins-Forge that has code to allow access to the ‘new’ way to upload files to Forge. I have it implemented, but I’m still getting a error where I am unable to upload files to a provided bucket. I also just built and used his code directly, no change except for my app ID and secret. I feel like this is an issue upstream in the .NET 6 SDK implementation of the Autodesk.Forge library. I can upload objects to buckets just fine if I roll back to an older version of the Autodesk.Forge .NET SDK, specifically 1.6.0 targeting .NET runtime 4.0.3+ – ShawnW. Sep 08 '22 at 18:35