Привет, Жуан Гильерме Безерра Алвес,
Вы можете воспользоваться преимуществами powershell, выполните следующие шаги:
- подготовьте элементы списка
подготовить файлы
запустить сценарий ниже:
#Set Variables
$SiteURL = "https://{tenant}.sharepoint.com/sites/abc"
$ListName = "yourlistname"
$Username='abc@xxx.onmicrosoft.com'
$Password = '***'
#region Credentials
[SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass)
#endregion Credentials
#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Credentials $PSCredentials
$Folderpath ="D:\mypdffolder"
ForEach ($File in (Get-ChildItem $FolderPath -File))
{
# try to find the corresponding item (has the same id)
$caml= @"
<View>
<Query>
<Where>
<Eq>
<FieldRef Name='Title' />
<Value Type='Text'>$($File.Name)</Value>
</Eq>
</Where>
</Query>
</View>
"@
$Items = Get-PnPListItem -List $ListName -Query $caml
if($Items -eq $null){
Write-Host "Do not find such an item that has the same id: $($File.Name)"
Continue
}
if($Items -is [system.array]){
$Item = $Items[0]
}else{
$Item = $Items
}
$AttachmentInfo = New-Object -TypeName Microsoft.SharePoint.Client.AttachmentCreationInformation
$AttachmentInfo.FileName = $File.Name
$AttachmentInfo.ContentStream = $File.OpenRead()
$AttchedFile = $Item.AttachmentFiles.Add($AttachmentInfo)
Invoke-PnPQuery
$AttachmentInfo.ContentStream.Close()
}
Ссылка do c: