标签: azure-storage-blobs

将 Blob 上传到 azure 返回 url

在 azure 中可能出现以下情况吗?:

我需要构建一个应用程序,该应用程序将根据用户提交进行一些繁重的处理,并将结果作为文件返回给用户。

  1. 第 1 步:用户通过 REST 调用将数据提交到我的端点(asp.net web api)
  2. 第 2 步:Web 角色返回报告的 url(尚未创建!)
  3. 第 3 步:我的端点将工作传递给工作角色并完成繁重的工作(2-3 分钟)
  4. 第 4 步:Worker 角色结束作业并创建报告文件并将其上传到 azure 存储 blob
  5. 第 X 步:如果可能的话,这就是我需要知道的:在用户拨打电话后的第 2 步,我需要立即将 URL 返回到尚未创建的报告(我不希望用户等待分钟或运行超时问题)。我知道该报告文件将是唯一的,因此我需要知道是否可以将 azure blob 存储的 url 生成到尚未创建的 report123.docx 中?但是,在报告准备好 2-3 分钟后,用户将能够使用步骤 2 中生成的 URL 访问该报告。

类似于:在用户拨打电话后,服务将响应:这是您的报告在 2 分钟后返回的网址...

azure azure-storage azure-storage-blobs

0
推荐指数
1
解决办法
652
查看次数

Azure连接字符串 - 未将对象引用设置为对象的实例

我正在尝试在Windows控制台应用程序中下载azure blob.当我构建和调试应用程序时,我的azure连接字符串抛出异常.这个字符串在我的其他asp.net应用程序中工作正常.

违规行是:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DefaultEndpointsProtocol=https;AccountName=xxxxx;AccountKey=xxxxx==;BlobEndpoint=https://xxxxx.blob.core.windows.net/;TableEndpoint=https://xxxxx.table.core.windows.net/;QueueEndpoint=https://xxxxx.queue.core.windows.net/;FileEndpoint=https://xxxxx.file.core.windows.net/"].ConnectionString);
Run Code Online (Sandbox Code Playgroud)

我的代码是:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
using System.Configuration;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Threading;

namespace CPGetAdverts
{
    class Program
    {
        static void Main(string[] args)
        {
            // Retrieve storage account from connection string.
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DefaultEndpointsProtocol=https;AccountName=xxxxx;AccountKey=xxxxx==;BlobEndpoint=https://xxxxx.blob.core.windows.net/;TableEndpoint=https://xxxxx.table.core.windows.net/;QueueEndpoint=https://xxxxx.queue.core.windows.net/;FileEndpoint=https://xxxxx.file.core.windows.net/"].ConnectionString);
            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            // Retrieve a reference to a container.
            var container = blobClient.GetContainerReference("newadverts").ListBlobs(); …
Run Code Online (Sandbox Code Playgroud)

c# console-application azure azure-storage-blobs

0
推荐指数
1
解决办法
919
查看次数

以编程方式删除批量中的Azure blob存储对象

是否可以以编程方式删除批量中的Azure blob对象?逐个删除对象有时需要几天时间.

我们在Azure Blob存储上放置了大量新文件以及我们想要删除的所有过时文件,以避免不必要的费用.

我用Google搜索了网络/ MSDN/Stack Overflow,发现2014年MSDN上只有一个主题是微软网站上的创建功能请求.

powershell bulk azure azure-storage-blobs

0
推荐指数
1
解决办法
563
查看次数

从流中读取 pdf 时未找到 PDF 标头签名,

我正在从 blob 容器下载文件并保存到流中并尝试阅读 pdf。

            //creating a Cloud Storage instance
        CloudStorageAccount StorageAccount = CloudStorageAccount.Parse(connectionstring);
        //Creating a Client to operate on blob
        CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();
        // fetching the container based on name
        CloudBlobContainer container = blobClient.GetContainerReference(containerName);
        //Get a reference to a blob within the container.
        CloudBlockBlob blob = container.GetBlockBlobReference(fileName);
        var memStream = new MemoryStream();
        blob.DownloadToStream(memStream);
        try
        {
            PdfReader reader = new PdfReader(memStream);
        }
        catch(Exception ex)
        {

        }
Run Code Online (Sandbox Code Playgroud)

例外:未找到 PDF 标头签名。

c# itext azure-storage-blobs

0
推荐指数
1
解决办法
2712
查看次数

执行 BlobClient.UploadAsync 时发生 HttpRequestException

我有以下代码将文件上传到我的 Azure 存储:

读取文件流如下:

   FileStream fileStream = File.OpenRead(filePath);
Run Code Online (Sandbox Code Playgroud)

并传递给函数 =>

 public async Task<Response<BlobContentInfo>> UploadBlob(string containerName, string blobName, Stream stream, string contentType,
            IDictionary<string, string> metadata = null)
        {
            IDictionary<string, string> metadataEncoded = new Dictionary<string, string>();
            if (metadata != null)
            {
                foreach (KeyValuePair<string, string> keyValuePair in metadata)
                {
                    string encodedValue = TextUtilities.Base64Encode(keyValuePair.Value);
                    metadataEncoded.Add(keyValuePair.Key, encodedValue);
                }
            }
            await using (stream)
            {
                BlobClient blobClient = GetBlobClient(containerName, blobName);
                BlobHttpHeaders httpHeaders = new BlobHttpHeaders { ContentType = contentType };
                BlobRequestConditions conditions = new BlobRequestConditions();
                Response<BlobContentInfo> uploadAsync …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-storage azure-storage-blobs azure-sdk

0
推荐指数
1
解决办法
1403
查看次数

Xamarin 的 WindowsAzure.Storage 库是否使用 NSUrlSession 进行文件上传?

问题陈述:我们需要将日志数据从 Xamarin.IOS 应用程序上传到 Azure 存储。日志不是由应用程序的用户创建的,并且在生成日志后,用户在任何时间内保持应用程序打开没有任何限制。我们希望可靠地上传我们的日志,并牢记以下几点:

  • 用户可能会将应用程序发送到后台
  • 文件大小可达 15MB
  • 当我们得到它们时,我们不在乎。我们愿意为此安排任务。

在查看此问题的潜在解决方案时,Xamarin 文档指出在 iOS7+ 中:

NSURLSession 允许我们创建任务来:

  1. 通过网络和设备中断传输内容。
  2. 上传和下载大文件(后台传输服务)。

所以看起来 NSURLSession 是这类工作的一个很好的候选者,但我想知道我是否在重新发明轮子。WindowsAzure.Storage客户端库是否尊重应用后台基于NSURLSession的上传实现,或者如果我想在后台上传数据,是否需要上传到我用POST方法控制的中间服务器,然后中继数据到 Azure 存储?公共 Azure 文档中似乎没有任何迹象表明可以通过计划任务完成上传。

azure xamarin.ios azure-storage-blobs xamarin nsurlsession

0
推荐指数
1
解决办法
150
查看次数

如何通过 node.js 中的@azure/storage-blob 在 blob 存储中获取文件的安全 url?

我正在使用@azure/storage-blob,我可以上传文件,但如何检索它?任何想法如何获取存储的 SAS url?

我需要生成几分钟后过期的 url,并且 url 是基于令牌的,因为容器不用于公共访问。请在 node.js 中提供帮助或指导我使用一些插件来帮助获取/生成 blob 存储中该文件的 sas url。先感谢您!

azure-storage-blobs node.js azure-blob-storage

0
推荐指数
1
解决办法
800
查看次数

获取 Azure blob 容器

我正在尝试获取一个容器(如果它存在的话)来创建它。

我的困惑是因为GetBlobContainersAsync返回 aBlobContainerItemCreateBlobContainerAsync返回 a BlobContainerClient

当我找到容器时,我怎样才能BlobContainerClientBlobContainerItem?

这是我到目前为止所拥有的:

var blobServiceClient = new BlobServiceClient(this.ConnectionString);

BlobContainerItem archiveContainer = null;
await foreach (var container in blobServiceClient.GetBlobContainersAsync(prefix: Uploader.ContainerName))
{
    if (String.Compare(container.Name, Uploader.ContainerName,
        CultureInfo.CurrentCulture, CompareOptions.Ordinal) == 0)
    {
        archiveContainer = ???
        break;
    }
}

if (archiveContainer == null)
{
    archiveContainer = await blobServiceClient.CreateBlobContainerAsync(Uploader.ContainerName);
}
Run Code Online (Sandbox Code Playgroud)

c# azure azure-storage azure-storage-blobs

0
推荐指数
1
解决办法
1013
查看次数

Azure 存储 SAS 密钥在到期日期前变得陈旧

SAS 密钥是否会因存储帐户中的设置更改而变得无效?例如:如果我们更改网络访问或 IP 白名单?SAS 密钥可以启用或不启用 IP,重要吗?

azure azure-storage azure-storage-blobs azure-blob-storage

0
推荐指数
1
解决办法
54
查看次数