从Azure网站的Blob存储中获取损坏的图像 [英] Getting broken images from blob storage in Azure websites

查看:103
本文介绍了从Azure网站的Blob存储中获取损坏的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的php代码似乎正确,(与Blob存储有关的部分).

My php code seems correct, (the part that talks to blob storage).

        //talk to blob storage, get links, based on file name

                $storageClient = $this->azure->get_blob_storage();

foreach($result as $photo)
{
$sharedAccessUrl[] = $storageClient->generateSharedAccessUrl(
               'container',
              $photo['File'],
               'b', 
               'r',
               $storageClient ->isoDate(time()),
               $storageClient ->isoDate(time() + 3000)
              );


}

      foreach($sharedAccessUrl as $item)
      {
     $pictures[] = $item;
      }

这将获取所有绝对URL链接,然后将其存储在数组中,将其传递给视图并检索图像.像这样:

This gets all the absolute url links, I then store it inside an array, pass it to the view and retrieve the images. Like this:

<img src="<?php echo $pictures[$i]; ?>" height=100px width="100px">

(where pictures[$i] = http://azure blobstorage etc...

在我的本地计算机上,每次刷新页面或浏览有图像的页面时,它们都可以正常加载.但是,当我将应用程序上传到蔚蓝的网站上时,经常会出现图像破碎的情况,因此每次出现图像时都需要刷新页面".尽管在我应该单击显示图像的div上的inspect元素上单击之后,尽管指向图像的链接是正确的.

On my local machine, everytime I refresh the page, or flick through pages where there are images, they all load up fine. However, when I upload my app onto azure web-sites, often I get broken images, and will then need to "refresh the page" every time it happens for the image to appear. This is despite the link to the image being correct, after I click on inspect element on the div where the image is suppose to appear.

我正在使用3个月试用版的Azure网站的共享版本". PHP版本与我的本地计算机完全相同,以及.net框架.

I am using "shared version" of azure web sites from the 3 month trial. PHP version is exactly the same as my local machine, along with the .net framework.

有人知道为什么会这样吗?

Does anyone have any idea why this is happening?

我已经检查了日志,但是它们没有帮助.

I have checked the logs but they are not helpful.

解决方案:

blob存储和天蓝色网站设置的时间似乎有所延迟.

There seems to be a delay with the times set at blob storage and azure web sites.

           $storageClient ->isoDate(time()-60),
           $storageClient ->isoDate(time() + 3000)

将-60添加到第一行.而且应该可以.

add -60 to the first line. And it should work.

推荐答案

好像您回答了自己的问题.它不是 delay ,而是 clock-drift 和计算节点与存储节点之间的时间同步.最好将开始时间设置为您希望链接开​​始工作之前的一分钟或两分钟(假设您打算使链接立即"开始工作).开始时没有任何危害,回到过去.

Looks like you answered your own question. It's not so much delay as it is clock-drift and time synchronization between compute nodes and storage nodes. It's always a good idea to set the start time to a minute or two prior to when you want the link to begin working (assuming you intend for the link to work "right now"). No harm start-time going back-in-time.

这篇关于从Azure网站的Blob存储中获取损坏的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆