我已经能够使用利用 Box API 的 C# 程序成功上传文件 Sample.pdf。(client_id、client_secret、code、POSTMAN 等)
BoxApi.V2.Authentication.OAuth2.OAuthToken newToken = default(BoxApi.V2.Authentication.OAuth2.OAuthToken);
clientID = "blah blah";
clientSecret = "blah blah";
TokenProvider tokenProvider = new TokenProvider(clientID, clientSecret);
StreamReader streamReader = default(StreamReader);
streamReader = System.IO.File.OpenText(@"C:\BoxApiRefreshToken.txt");
oldRefreshToken = streamReader.ReadToEnd();
streamReader.Close();
newToken = tokenProvider.RefreshAccessToken(oldRefreshToken);
BoxManager boxManager = new BoxManager(newToken.AccessToken);
StreamWriter streamWriter = new StreamWriter(@"C:\BoxApiRefreshToken.txt");
streamWriter.Write(newToken.RefreshToken);
streamWriter.Close();
Folder rootFolder = default(Folder);
rootFolder = boxManager.GetFolder(Folder.Root);
BoxApi.V2.Model.File file = boxManager.CreateFile(rootFolder, attachedFilename, ConvertStreamToByteArray(stream));
上传后,我只是想知道如何检索公共 URL 以在 C# 程序中访问此文件?我认为 sharedlink 是一种方式,但我不确定如何。
谢谢