将自定义缩略图上载到Sharepoint图像库 [英] Upload Custom Thumbnail to Sharepoint Image library

查看:78
本文介绍了将自定义缩略图上载到Sharepoint图像库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Webpart可以将图像上传到SharePoint图像库,而SP可以自动生成缩略图.

I've got a webpart to upload images to a SharePoint image library, and SP does the thumbnail generation automagically.

我想为我的用户提供上传自己的缩略图的选项,而无需SP为他们做.

I'd like to give my users the options of uploading their own thumbnails, without SP doing it for them.

有什么想法吗?

我确实知道SP会将缩略图存储在库中的/_t文件夹中,但是我似乎无法以编程方式在其中写入文件...这就是我想要做的:

I do know that SP will store the thumbnails in a folder /_t in the library, but I can't seem to write files there programatically... This is what I'm tring to do:

 using (SPSite objSite = new SPSite("http://foo.com/"))
        {
            using (SPWeb objWeb = objSite.OpenWeb())
            {
                //Need to abstract this library definition...
                SPFolder mylibrary = objWeb.Folders["Media/_t"];
                // Set AllowUnsafeUpdates = true to avoid security error
                objWeb.AllowUnsafeUpdates = true;
                mylibrary.Files.Add(System.IO.Path.GetFileName(filename), bytes);
            }
        }

如果这样做,我会收到一条错误消息,提示该值不在预期范围内.

If I do that I get an error message saying that value does not fall within expected range.

有什么想法吗?

推荐答案

我认为SharePoint不会通过Folders集合来公开/_ t 文件夹.但是,可以使用以下方式访问它们:

I don't think the /_t folders are publicised by SharePoint through the Folders collection. However they are accessible by using:

SPFolder mylibrary = objWeb.GetFolder("Media/_t");

这篇关于将自定义缩略图上载到Sharepoint图像库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆