Tag: azure storage blobs

从Azure Blob存储下载文件的示例

我可以通过Node / Express将file upload到Azure blob存储,而不会出现问题,但是已经find了关于如何下载文件的非常less量的文档/完整示例。 我在教程页面find了这个,但没有任何运气: blobSvc.getBlobToStream('mycontainer', 'myblob', fs.createWriteStream('output.txt'), function(error, result, response){ if(!error){ // blob retrieved } }); 是否有其他人使用node.js / express从Azure blob存储下载文件? 你使用Azure还是其他方法(例如请求)? 您可以分享如何从Azure获取文件并将其stream式传输到文件夹?

Nodejs使用.createBlockBlobFromLocalFile()将base64映像上传到azure blob存储

我想通过Base64表单上传从networking应用和移动应用发送的用户的个人资料图片。 在POST请求上,他们需要在正文上发送一个JSON 。 { "name":"profile-pic-123.jpg", "file":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxQTEhIUEhIUFBUV…K9rk8hCAEkjFMUYiEAI+nHIpsQh0AkisDYRTOiCAbWVtgCtI6IlkHh7LDTQXLH0EIQBj//2Q==" // the base64 image } 现在在服务器端使用Node和Express ,我使用了这个名为azure-storage npm模块,它提供了一个使用web服务将file upload到azure blob存储的好方法。 但是有一些我无法理解的。 这里是我的控制器的一部分代码。 我成功创build了所有必要的连接和键,以及创build一个blobService : controllers.upload = function(req, res, next){ // … // generated some sastoken up here // etc. // … var uploadOptions = { container: 'mycontainer', blob: req.body.name, // im not sure about this path: req.body.file // im […]

从自定义node.js API中检索Azure Blob

我想从Microsoft Azure blob存储容器中检索图像的二进制数据。 我已经使用AZSCloudBlobContainer上的以下function,从iOS应用程序成功地将图像上传到Azure上的存储容器。 blockBlob.uploadFromData(imageData, completionHandler: 我也可以使用AZSCloudBlob上的以下function直接将其成功下载到iOS应用程序。 blockBlob.downloadToDataWithCompletionHandler({(error: NSError?, data: NSData?) 我遇到的问题是,我希望能够从node.js服务器端脚本检索图像,而不是直接从应用程序。 其中,我已经尝试了下面的代码… var containerName = 'containerName'; var blobService = storage.createBlobService(accountName, accountKey); var blobName = 'blobname'; var fs = require('fs'); var stream = fs.createWriteStream('output.txt'); blobService.getBlobToStream(containerName, blobName, stream, function (error, result, response2) { response.json(result); }); 该响应检索blob信息,但我不知道如何获得图像的实际二进制数据? ({ blobType = BlockBlob; container = containername; contentLength = 14593; […]

整个存储帐户的Azure共享访问签名

我正在使用API​​(node.js)为使用Azure移动服务的iOS应用程序生成只读共享访问签名。 API使用以下代码生成SAS … var azure = require('azure-storage'); var blobService = azure.createBlobService(accountName, accountKey); var sas = blobService.generateSharedAccessSignature("containerName", null, sharedAccessPolicy); 当我想要SAS访问一个容器时,这很好用。 但我真的需要访问存储帐户中的所有容器。 我明显可以做到这一点与每个容器单独的API调用,但这将需要数百个额外的电话。 我到处寻找一个解决scheme,但我不能得到任何工作,我非常感激知道是否有一种方法来生成一个存储帐户中的所有容器SAS?

添加caching控制和Expires头到Azure Blob存储节点JS

我正在使用Azure存储来提供静态文件blob,但是我想在提供服务时将caching控制和Expires头添加到文件/ Blob,以降低带宽成本。 但是我正在使用节点JS 我如何做到这一点? 这是我到现在为止: 更简单的解决scheme: jsfiddle.net/fbqsfap2 //https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=properties function updateBlob(blobName, containerName, accountName, properties) { let xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == XMLHttpRequest.DONE ) { console.log(xmlhttp.status); if (xmlhttp.status == 200) { const updatedPropertiesStr = getPropertiesKeysStr(properties); console.log("Update sucessfully ", updatedPropertiesStr); } else if (xmlhttp.status == 400) { console.log('There was an error 400'); […]

Stream.pause在将file upload到azure色时不是函数

我声明我的multerconfiguration如下: const storage = multer.memoryStorage() const upload = multer({ limits: { fileSize: 1000 * 1000 * 10 // 10 Megabytes }, storage: storage }); 然后在我的快车路线: …//On api.post() {} console.log(file); … 这输出文件,一个缓冲区,这是伟大的! 但是,当我打电话给: createBlockBlobFromStream(containerName, fileName, file, size) 我得到错误streamstream.pause is not a function上传开始时由azure-storage调用stream.pause is not a function ,因为sdk想要在Azure云blob服务继续之前等待获得200 ,这是有道理的。 但是,它不认为我通过的文件有属性pause() 。 任何人都遇到过这个? 我在某处读到,由multer创build的stream不是正确的共振峰,我需要将它包裹在streamifier或其他包中。

在Nodejs中用Graphicsmagick调整图像大小会生成emty文件

我试图调整现有的图像,然后将其上传到Azure存储,但没有成功… gm("https://sinkroon.blob.core.windows.net/sinkroonboilerplate/dakterras1.jpg") .resize(50, 50) .stream(function (err, stdout, stderr) { var writeStream = blobSvc.createWriteStreamToBlockBlob( containerName, 'test.jpg', { contentType: 'image/jpg' }, function (error, result, response) { if (error) { console.error(error); } else { } }); stdout.pipe(writeStream); }); 这会生成一个空的图像: https : //sinkroon.blob.core.windows.net/sinkroonboilerplate/test.jpg 不知道我在做什么错…任何人?

Azure Blob存储哈希不匹配(完整性检查失败)

我正在关注http://willi.am/blog/2014/07/03/azure-blob-storage-and-node-downloading-blobs/ 。 但是,尽pipe代码完全相同,但是当我下载Blob时,Azure会给出错误: [错误:哈希不匹配(完整性检查失败),期望值是…] 正在运行的行是blobService.getBlobToText,其中blobService是与Azure的连接(createBlobService …) 这是怎么回事? :S 我的代码如下: // Azure test function downloadImageAsText(blobService, containerName, blobName) { blobService.getBlobToText( containerName, blobName, function(err, blobContent, blob) { if (err) { console.error("Couldn't download blob %s", blobName); console.error(err); } else { console.log("Sucessfully downloaded blob %s", blobName); console.log(blobContent); } }); } function uploadImage(blobService, containerName, blobName, fileName) { blobService.getBlobProperties( containerName, blobName, function(err, […]

Azure存储将图像从blob复制到blob

我正在使用Azure Storage Nodejs ,我需要做的是将图像从一个blob复制到另一个。 首先,我试图getBlobToFile获取磁盘中的临时位置的图像,然后从该临时位置createBlockBlobFromFile 。 这个方法完成了任务,但由于某种原因,它没有完全复制10%的情况。 我试图使用getBlobToText和结果放入createBlockBlobFromText ,也试图把需要blob的选项是图像容器。 该方法完全失败,复制后图像甚至不打开。 也许有一种方法来复制blob文件并将其粘贴到其他blobl,但我没有find该方法。 我还可以做些什么?

azurestorage和NodeJS中的getaddrinfo错误

我正在做和将文件发送到Azure存储容器的应用程序,然后将消息发送到Azure队列。 当我达到1000〜1020条消息时,我不能发送更多的文件和消息。 我也注意到,当我尝试检查队列中有多less条消息时,我有一个错误。 错误是: { [Error: getaddrinfo EADDRINFO] code: 'EADDRINFO', errno: 'EADDRINFO', syscall: 'getaddrinfo' } 我的代码是: function start(pos) { var entry = inputs[pos]; // The array stars at 0 (zero) console.log(entry); // Print current file //Let's start the uploading blobSvcInput.createContainerIfNotExists(containerInput, function(error, result, response){ // this function will create a container in Azure Storage (if this […]