通过Perl HTTP :: DAV将Excel文件上传到MS Sharepoint站点

时间:2015-01-05 09:18:57

标签: perl sharepoint sharepoint-2010

我在将Excel文件上传到MS SharePoint网站时遇到问题。 我收到以下错误。

Couldn't open https://one.mysite.net/sites/Fin/Shared Documents/
Fin Projects/Project Reports: Unauthorized.
Wont put unless I can lock for 10 minutes

在浏览器中,我可以登录并查看[也可以上传和下载]来自Sharepoint网站的文件。

这是我的代码:

use HTTP::DAV;

$d   = new HTTP::DAV;
$url = "https://one.mysite.net/sites/Fin/Shared Documents/Fin Projects/Project Reports";

$d->credentials(
    -user  => "My_User_ID",
    -pass  => "123456789_pwd",
    -url   => $url,
    -realm => "DAV Realm"
);

if ( $d->open( -url=> $url ) ) {
    print "successfully logged in";
}
else {
    print "Couldn't open $url: " .$d->message . "\n";
}

# Make a null lock on newdir
$d->lock( -url => "$url", -timeout => "10m" ) 
  or die "Wont put unless I can lock for 10 minutes\n";

# Upload multiple files to newdir.
if ( $d->put(
       -local => "C:\Users\My Desktop\MY_XLSX_FILE.xlsx",
       -url => $url
) ) {
    print "successfully uploaded multiple files to $url\n";
} else {
    print "put failed: " . $d->message . "\n";
}

$d->unlock( -url => $url );

提前致谢!

Gayathri T

0 个答案:

没有答案