sharepoint文档库需要设置权限才能让用户读取对应的文件,为了保证文件的安全性,我们只给管理员设置权限,其他用户通过管理员权限读取下载文件;
注意:通过管理员权限一般指设置流的run only as user ,将sharepoint连接器固定为管理员的连接器
文件读取1:我们在用户读取的时候,先授权,再进行读取;
文件读取2:我们结合sharepoint和用户one drive读取文件,使用管理员运行automate获取文件content,再通过automate将文件content上传至当前用户one drive里面 这样用户没有任何权限,但是同样可以上读取sharpoint文件,上传时我们也是通过管理员权限运行流。具体如下:
上传到one drive,返回地址
文件预览:
使用powerApp自带的预览控件,图片使用img直接展示base64,pdf直接使用PdfViewer,其他文档格式需要先转换成pdf,再使用PdfViewer;
1.图片
使用getcontent之后,将返回的文件内容拼接成base64,直接放在Imaged的image
UpdateContext(
{
FileContent: "data:" & Switch(
Lower(
Last(
Split(
ThisItem.FileName,
"."
)
).Value
),
"png",
"image/png",
"jpg",
"image/jpeg",
"jpeg",
"image/jpeg",
"pdf",
"application/pdf",
"xlsx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"xls",
"application/vnd.ms-excel",
"docx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"doc",
"application/msword",
"application/octet-stream"// 默认值
) & ";base64," & Result.FileContent
}
);
2.pdf的同上 获取到文件content 然后拼接base64,放到pdfviewer的Document属性即可
3.txt文档,获取到文件content 用标签控件展示即可
4.world,excle 获取到文件属性,将 "/thumbnail" 替换成"/pdf";转换格式时,原来的格式可能会展示有误,看个人能否接受
If(
Lower(
Last(
Split(
Text(Value.'{FilenameWithExtension}'),
"."
)
).Value
) = "pdf",
Text(ParseJSON(JSON(Value.'{Thumbnail}')).Large),
Substitute(
Text(ParseJSON(JSON(Value.'{Thumbnail}')).Large),
"/thumbnail",
"/pdf"
)
)
excle文件格式预览,格式改变,原来的sheet页也会放置在同一页
world格式的: