2017-06-05 122 views
0

如何獲取外部文件的上次修改時間戳?如何獲取外部文件的上次修改時間戳?

我試圖使用xhr.getResponseHeader("Last-Modified"),我得到了前面修改過的時間,但不是最近修改過的時間戳。 例如:Fri, 02 Jun 2017 04:39:18 GMT而我應該得到今天的日期。

+1

'xhr.getResponseHeader( '的Last-Modified')'是這樣做的正確方法。你應該環顧四周,你的問題可能在其他地方。 –

+0

客戶端只能通過服務器發送的內容 –

+0

稍作修改。 –

回答

0

可以使用get響應爲Blob,通過BlobFile構造得到.lastModifiedDate屬性值

fetch("/path/to/file") 
.then(response => response.blob()) 
.then(blob => { 
    const file = new File([blob], blob.name); 
    console.log(file.lastModifiedDate, file.lastModified); 
}); 
相關問題