Dropbox API - UploadAsync 值应该匹配
Dropbox API - UploadAsync Value Should Match
我正在尝试使用 Dropbox API 来上传文件。
string accesstoken = "token";
using (DropboxClient client =
new DropboxClient(accesstoken, new DropboxClientConfig("NameOfApp")))
{
string[] spitInputFileName = file.FileName.Split(new string[] { "\" }, StringSplitOptions.RemoveEmptyEntries);
string filenameAndExtension = spitInputFileName[spitInputFileName.Length - 1];
string[] filenameAndExtensionSplit = filenameAndExtension.Split('.');
string originalFileName = filenameAndExtensionSplit[0];
string originalExtension = filenameAndExtensionSplit[1];
String filename = "" + originalFileName + Guid.NewGuid().ToString().Replace("-", "") + "." + originalExtension;
var updated = client.Files.UploadAsync(
filename,
mode: WriteMode.Overwrite.Overwrite.Instance,
body: file.InputStream).Result;
var result = client.Sharing.CreateSharedLinkWithSettingsAsync(filename).Result;
体内:file.InputStream.Result;部分,遇到以下错误:
An exception of type 'System.ArgumentOutOfRangeException' occurred in Dropbox.Api.dll but was not handled in user code
Value should match pattern '\A(?:(/(.|[\r\n])*)|(ns:[0-9]+(/.*)?)|(id:.*))\z'
这个异常的原因是什么?
路径应以“/”开头。
文件路径应该是这样的:
/test.txt
你的情况:
String filename = "/" + originalFileName + Guid.NewGuid().ToString().Replace("-", "") + "." + originalExtension;
我正在尝试使用 Dropbox API 来上传文件。
string accesstoken = "token";
using (DropboxClient client =
new DropboxClient(accesstoken, new DropboxClientConfig("NameOfApp")))
{
string[] spitInputFileName = file.FileName.Split(new string[] { "\" }, StringSplitOptions.RemoveEmptyEntries);
string filenameAndExtension = spitInputFileName[spitInputFileName.Length - 1];
string[] filenameAndExtensionSplit = filenameAndExtension.Split('.');
string originalFileName = filenameAndExtensionSplit[0];
string originalExtension = filenameAndExtensionSplit[1];
String filename = "" + originalFileName + Guid.NewGuid().ToString().Replace("-", "") + "." + originalExtension;
var updated = client.Files.UploadAsync(
filename,
mode: WriteMode.Overwrite.Overwrite.Instance,
body: file.InputStream).Result;
var result = client.Sharing.CreateSharedLinkWithSettingsAsync(filename).Result;
体内:file.InputStream.Result;部分,遇到以下错误:
An exception of type 'System.ArgumentOutOfRangeException' occurred in Dropbox.Api.dll but was not handled in user code
Value should match pattern '\A(?:(/(.|[\r\n])*)|(ns:[0-9]+(/.*)?)|(id:.*))\z'
这个异常的原因是什么?
路径应以“/”开头。 文件路径应该是这样的:
/test.txt
你的情况:
String filename = "/" + originalFileName + Guid.NewGuid().ToString().Replace("-", "") + "." + originalExtension;