vbUploaded Image to Sharepoint using Graph API不包含任何内容(.NET)



我已经使用以下方法将文件(docx,xlsx(上传到我们的共享点。现在我正在尝试将图像(png,jpg(上传到同一个库。我没有得到任何错误,上传的图像作为流。此图像也没有可用的预览,我无法下载。创建的sharepoint文件如下所示:上传的共享点图像

我还尝试使用HeaderOptions列表,并将内容类型设置为";image/png";。

我的流包含流和图像格式。我能够将我的流转换回图像,并将其保存到我的文件系统中。所以我认为这不取决于我的流媒体内容。由于我的功能可以正常使用docx文件,我也认为这不取决于任何权限或连接主题。。。

这是我的上传功能:

Public Async Function createImageUploadAsync(Stream As Stream, DriveItemID As String, Rootpath As String, filename As String) As Task(Of String)
Dim FileId As String = ""
Try
'Dim Option As List(Of HeaderOption) = New List(Of HeaderOption) From {
'    New HeaderOption("Content-Type", "image/png")
'    }
Dim ms As MemoryStream = New MemoryStream
If _GraphClient IsNot Nothing Then
Dim uploadedfile = Await _GraphClient.Sites(__DAL.SiteID).Lists(DriveItemID).Drive.Root.ItemWithPath(Rootpath + filename).Content.Request().PutAsync(Of DriveItem)(Stream)
FileId = uploadedfile.id
End If
Catch ex As Exception
If __DAL.Testbetrieb Then Stop
__Prot.Err(ex, True)
End Try
Return FileId
End Function

为什么我上传的图片是空的,你有什么建议吗?

如果其他人也面临同样的问题。。。

经过数小时的研究和测试,我找到了解决问题的方法:

你可以上传PDF,Word和Excel文件作为内存流,正如我上面解释的。但是你不能上传图像作为内存流。您必须将图像读取为FileStream,然后才能以相同的方式上传。

最新更新