.NET SDK uploading files - file never appears
I'm struggling to make heads or tails of the API and the .NET SDK. My goal seems simple: enable a .NET application to upload files to a box.com account. I'm having trouble believing that I'm approaching this correctly because there seem to be an incredibly complicated number of interactions and steps to take here. I have:
* created an Application, complete with an RSA key pair
* in my box account, authorized that app under Custom Applications
* installed the SDK from nuget, and had success authenticating via BoxJWTAuth using my application's ClientID/Secret and RSA key; and my account's EnterpriseID
* created an "admin token" (??) and seemingly used that token to upload a file
The API reports my file is uploaded, its ItemStatus post-upload is good. The file, however, never appears in my box account.
What am I potentially missing? I'm surely not understanding the concepts involved in this API, which is frankly frustrating to wrap my head around.
-
Your approach is correct. The steps you followed created a Service Account, which represents your application within a Box Enterprise. This application has its own content store, and depending on the permissions you enabled it also can upload files to a user's account.
When you uploaded the file using the steps you described, it was stored in the application's content store. You can access the file in the Box web app by going to the Content Manager page.
To upload a file to a user's account, you can use the As-User header with a Service Account. Here is the documentation for using the As-User header with our .NET SDK.
-
So, for me this is where the SDK, or maybe just the documentation, has failed me. I've read all the docs and I'm still totally confused by service accounts and "app users"; why in the world there's a separate content store hidden away in a place I had no idea to look; why the content uploaded by my "service account" went in there in the first place, a feature which I haven't seen documented anywhere. It's not clear to me how to determine the user ID for any user. You pointed me to a feature that is so poorly documented in the SDK that half of the two sentences devoted to it are instructions to go elsewhere for instructions.
Can we just use FTPS and be happy?
-
This is the code you are referring to I believe. I am using JWT Authentication however, so I don't have an access token or refresh token in order to create a new OAuthSession(). Is there a way to create a box client using the JWT Authentication method? Should I be generating access and refresh tokens when authenticating with JWT?
Thanks!
var config = new BoxConfig(, , , , 3600, "bearer"); var userId = "12345678" var userClient = new BoxClient(config, auth, asUser: userId); //returns root folder items for the user with ID '12345678' var items = await userClient.FoldersManager.GetFolderItemsAsync("0", 500);
サインインしてコメントを残してください。
コメント
3件のコメント