无法设置使用 FrontPage RPC 上传到 SharePoint 的文件的修改日期

发布于 2025-01-08 17:28:40 字数 2591 浏览 4 评论 0原文

当我使用 FPRC 使用以下代码将文件上传到 SharePoint 来设置 vti_timelastmodified 时,显示的修改日期始终是当前日期:

 Public Sub UploadSharepointFile(ByVal sSourcePath As String, ByVal sContent As String, ByVal SiteURL As String, ByVal DocName As String, _
                            Optional ByVal sOrigPath As String, Optional ByVal sOrigName As String, _
                            Optional ByVal checkincomment As String, Optional ModDate As Date, Optional FileID As Long)


Dim stream As New ADODB.stream
Dim stream2 As New ADODB.stream
Dim xmlHTTP As New MSXML2.xmlHTTP

    strHeader = "method=put+document%3a12.0.4518.1016" & _
                "&service_name=%2f" & _
                "&document=[document_name=" & Escape(DocName) & _
                ";meta_info=[Original%20Path%3bSW%7c" & Escape(sOrigPath) & _
                ";Original%20Name%3bSW%7c" & Escape(sOrigName) & _
                ";vti_timelastmodified3bTR%7c" & Format(ModDate, "DD+MMM+YYYY+hh:mm:ss") & _
                "]]&put_option=overwrite,createdir,migrationsemantics" & _
                "&comment=" & _
                "&keep%5fchecked%5fout=false" & vbLf

byteArray = StringToByteArray(strHeader)

stream.Open
stream.Type = 1    ''adTypeBinary
stream.Write byteArray


stream2.Open
stream2.Type = 1   'adTypeBinary
stream2.LoadFromFile sSourcePath

stream2.CopyTo stream, -1
stream.Position = 0

'Set xmlHTTP = CreateObject("MSXML2.XMLHTTP")
xmlHTTP.Open "POST", SiteURL + "/_vti_bin/_vti_aut/author.dll", False, UserName, Password
xmlHTTP.setRequestHeader "Content-Type", "application/x-vermeer-urlencoded"
xmlHTTP.setRequestHeader "X-Vermeer-Content-Type", "application/x-vermeer-urlencoded"
xmlHTTP.setRequestHeader "User-Agent", "FrontPage"
xmlHTTP.send stream

如果我按如下方式设置自定义日期字段“原始修改”,则正确的日期会出现在新字段

strHeader = "method=put+document%3a12.0.4518.1016" & _
                "&service_name=%2f" & _
                "&document=[document_name=" & Escape(DocName) & _
                ";meta_info=[Original%20Path%3bSW%7c" & Escape(sOrigPath) & _
                ";Original%20Name%3bSW%7c" & Escape(sOrigName) & _
                ";Original%20Modified%3bTR%7c" & Format(ModDate, "DD+MMM+YYYY+hh:mm:ss") & _
                "]]&put_option=overwrite,createdir,migrationsemantics" & _
                "&comment=" & _
                "&keep%5fchecked%5fout=false" & vbLf
End If

中可以将uplaod上的vti_lasttimemodified修改为预设值吗?

西蒙·克拉维斯

When I upload files to SharePoint using FPRC with the following code to set vti_timelastmodified the Modified date shown is always the current date:

 Public Sub UploadSharepointFile(ByVal sSourcePath As String, ByVal sContent As String, ByVal SiteURL As String, ByVal DocName As String, _
                            Optional ByVal sOrigPath As String, Optional ByVal sOrigName As String, _
                            Optional ByVal checkincomment As String, Optional ModDate As Date, Optional FileID As Long)


Dim stream As New ADODB.stream
Dim stream2 As New ADODB.stream
Dim xmlHTTP As New MSXML2.xmlHTTP

    strHeader = "method=put+document%3a12.0.4518.1016" & _
                "&service_name=%2f" & _
                "&document=[document_name=" & Escape(DocName) & _
                ";meta_info=[Original%20Path%3bSW%7c" & Escape(sOrigPath) & _
                ";Original%20Name%3bSW%7c" & Escape(sOrigName) & _
                ";vti_timelastmodified3bTR%7c" & Format(ModDate, "DD+MMM+YYYY+hh:mm:ss") & _
                "]]&put_option=overwrite,createdir,migrationsemantics" & _
                "&comment=" & _
                "&keep%5fchecked%5fout=false" & vbLf

byteArray = StringToByteArray(strHeader)

stream.Open
stream.Type = 1    ''adTypeBinary
stream.Write byteArray


stream2.Open
stream2.Type = 1   'adTypeBinary
stream2.LoadFromFile sSourcePath

stream2.CopyTo stream, -1
stream.Position = 0

'Set xmlHTTP = CreateObject("MSXML2.XMLHTTP")
xmlHTTP.Open "POST", SiteURL + "/_vti_bin/_vti_aut/author.dll", False, UserName, Password
xmlHTTP.setRequestHeader "Content-Type", "application/x-vermeer-urlencoded"
xmlHTTP.setRequestHeader "X-Vermeer-Content-Type", "application/x-vermeer-urlencoded"
xmlHTTP.setRequestHeader "User-Agent", "FrontPage"
xmlHTTP.send stream

If I set a custom date field 'Original Modified' as follows then the correct date appears in the new field

strHeader = "method=put+document%3a12.0.4518.1016" & _
                "&service_name=%2f" & _
                "&document=[document_name=" & Escape(DocName) & _
                ";meta_info=[Original%20Path%3bSW%7c" & Escape(sOrigPath) & _
                ";Original%20Name%3bSW%7c" & Escape(sOrigName) & _
                ";Original%20Modified%3bTR%7c" & Format(ModDate, "DD+MMM+YYYY+hh:mm:ss") & _
                "]]&put_option=overwrite,createdir,migrationsemantics" & _
                "&comment=" & _
                "&keep%5fchecked%5fout=false" & vbLf
End If

Is there a way in can modify vti_lasttimemodified on uplaod to a preset value?

Simon Kravis

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文