我正在使用Microsoft.WindowsAzure.Storage.DataMovement库进行目录上传,如下所示
$(document).ready(function() {
function setCookie(cname, cvalue) {
document.cookie = cname + "=" + cvalue + ";path=/";
}
function getCookie(cname) {
const name = cname + "=";
const ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
setCookies('INITIAL_URL', document.URL);
$("#reset").attr("href", getCookie('INITIAL_URL'));
});
我认识到如果我用相同的名称更改了图像,则函数会忽略图像并在文件存在时返回异常。如果更改了datemodified,如何替换图像?当然,首先在我的本地电脑上修改日期,并且应该同步azure。
答案 0 :(得分:2)
我刚想通了Microsoft.WindowsAzure.Storage.DataMovement包有一个新的更新,我安装了0.4.1版本。看起来它暴露了新的方法和事件。 我不确定这是否在版本0.3(我之前的版本)中可用,但我在安装版本0.4.1 Microsoft.WindowsAzure.Storage.DataMovement包后才知道。下面的代码将比较源和目标,并决定是否应覆盖。我希望它可以帮助其他人解决同样的问题。
context.ShouldOverwriteCallback = (source, destination) =>
{
var sourceFile = new FileInfo((string)source);
var destBlob = destination as CloudBlob;
return sourceFile.LastWriteTimeUtc > destBlob.Properties.LastModified;
};