简体   繁体   English

Dropbox文件上传未显示409错误

[英]Dropbox file uploading not showing 409 error

I'm uploading file using Dropbox core API. 我正在使用Dropbox核心API上传文件。 I have written the upload code like- 我已将上传代码编写为-

RequestResult strReq = OAuthUtility.Put
                            (
                            "https://api-content.dropbox.com/1/files_put/auto/",
                            new HttpParameterCollection
                        {
                            {"access_token", "Token"},
                            {"path","/file.txt"},
                            {"overwrite", "false"}, 
                            {"autorename","false"}, 
                            {stream}
                        }
                            );

Suppose there is a existing file in root folder named file.txt and I'm again trying to upload the same name file to same folder.I have written overwrite= false and autorename=false but surprisingly there is no error status code returning in the response.Always returning the success code 200 in the response.I need to show the proper error code. 假设根文件夹中存在一个名为file.txt的文件,我再次尝试将相同名称的文件上传到同一文件夹。我编写了overwrite = false和autorename = false,但是令人惊讶的是,在该目录中没有错误状态代码返回总是在响应中返回成功代码200.我需要显示正确的错误代码。

Two things stand out: 两件事脱颖而出:

  1. Your URL is https://api-content.dropbox.com/1/files_put/auto/ , but it should be (for this example) https://api-content.dropbox.com/1/files_put/auto/file.txt . 您的URL是https://api-content.dropbox.com/1/files_put/auto/ ,但对于此示例,它应该是https://api-content.dropbox.com/1/files_put/auto/file.txt The path parameter should be removed from the HttpParameterCollection . path参数应从HttpParameterCollection删除。
  2. I'm unfamiliar with the library you're using, but are you sure that those parameters are turned into query parameters and that stream becomes the HTTP body? 我不熟悉您使用的库,但是您确定这些参数已转换为查询参数,并且该stream成为HTTP正文吗? Ie the resulting URL should be https://api-content.dropbox.com/1/files_put/auto/file.txt?overwrite=false&autorename=false&access_token=<TOKEN> , and then the file content should go in the body of the request. 也就是说,生成的URL应该是https://api-content.dropbox.com/1/files_put/auto/file.txt?overwrite=false&autorename=false&access_token=<TOKEN> ,然后文件内容应放在请求。 Please make sure this is what's happening. 请确保这是正在发生的事情。

Please also share the body that comes back with the 200 response. 请同时分享200响应返回的正文。 It should tell you, for example, the path of the file that got written. 例如,它应该告诉您所写文件的路径。

Note that if you upload the exact same file content to the same path, it doesn't count as a conflict, so when looking for a 409, make sure you're uploading different content to the file. 请注意,如果将完全相同的文件内容上载到同一路径,则不会算作冲突,因此在查找409时,请确保将不同的内容上载到文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM