c# - Windows Azure : Server Error , 404 - 找不到文件或目录

标签 c# azure blob

我想将一些大小为 35MB 的文件上传到 blob 容器。 我已经编写了代码,将数据分割成 block 并将其上传到 blob 容器并使用 PUT 形成一个 blob。

我测试了一些大小为2MB的文件的代码或其他东西......它运行良好。但是当我尝试处理一个大的 MB 文件时,它给了我这个错误

Server Error
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

当我尝试大小为 6MB 的文件时,它给了我这个错误..

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

谁能告诉我,如何解决这个问题...

<小时/>

上传 blob 的代码。

protected void ButUploadBlocks_click(object sender, EventArgs e)
        {

            // store upladed file as a blob storage
            if (uplFileUpload.HasFile)
            {
                name = uplFileUpload.FileName;
                byte[] byteArray = uplFileUpload.FileBytes;
                Int64 contentLength = byteArray.Length;
                int numBytesPerBlock = 250 *1024; // 250KB per block
                int blocksCount = (int)Math.Ceiling((double)contentLength / numBytesPerBlock);  // number of blocks 
                MemoryStream ms ;
                int length = 0;
                List<string>BlockIds = new List<string>();
                string block;
                int offset = 0;

                // get refernce to the cloud blob container
                CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("documents");

                if (textbox.Text != "")
                {
                    name = textbox.Text + "/" + name;

                }
                // set the name for the uploading files
                string UploadDocName = name;

                // get the blob reference and set the metadata properties
                CloudBlockBlob blob = blobContainer.GetBlockBlobReference(UploadDocName);
                blob.Properties.ContentType = uplFileUpload.PostedFile.ContentType;

                for (int i = 0; i < blocksCount; i++, offset = offset + numBytesPerBlock)
                {
                    block = Convert.ToBase64String(BitConverter.GetBytes(i));
                    ms = new MemoryStream();
                    if (i == (blocksCount - 1))
                    {
                        length = (int)contentLength - offset;
                    }
                    else
                    {
                        length = numBytesPerBlock;
                    }
                    ms.Write(byteArray, offset, length);
                    ms.Position = 0;

                    blob.PutBlock(block, ms, null);
                    BlockIds.Add(block);
                }

                blob.PutBlockList(BlockIds);

                blob.Metadata["FILETYPE"] = "text";
            }
        }

最佳答案

我的猜测是您遇到了 ASP.NET 限制...存在最大请求大小以及最大请求超时。我会在 web.config 中进行建议的更改,看看有什么异常。

关于c# - Windows Azure : Server Error , 404 - 找不到文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2633564/

相关文章:

c# - Linq Query 连接重叠范围并构造新的连续范围

c# - MVC - 从 ListBoxFor 获取 ViewModel 对象

c# - 对象 dbo 无效。用户购物项目 - Azure IIS 和 SQL Server

function - 远程调用时Azure函数突然返回401未经授权

ruby-on-rails - 将 nokogiri (或任何内部)对象保存到数据库是个好主意吗?

azure - 尝试创建 Azure 镜像时出现无效 VHD 路径错误

c# - 在 C# 中以指数格式表示 double 值

c# - 如何在 Azure 移动应用上托管 API

azure - 如何向我的应用程序添加权限,以便它可以使用 Office 365 统一 API(预览版)

php - 图像(SQL Server)和longblob(MySQL)有什么区别?