Monthly Archives: July 2015

Generate thumbnail of a document stored in SharePoint from its URL

In a previous article, we have seen how to generate a document thumbnail from its metadata (siteId, webId, uniqueId, docId…) retrieved from the search engine.

With these metadata, you just have to build and call an URL such as the following :

https://tenant.sharepoint.com/_layouts/15/getpreview.ashx?guidFile=<GUID>&guidSite=<GUID>&guidWeb=<GUID>&docid=<Int>&metadatatoken=<String>

Although easy to implement, this solution is not convenient every time, especially when you don’t use the search engine to retrieve data.

For example, when you use the Video REST API or the SharePoint REST API to manipulate list items, you don’t retrieve some of the required properties to generate the preview as described in our previous article.

One solution should be to query the search engine for the associated file to retrieve required metadata, then build and call the URL to generate the preview. This solution works very well but it’s pretty inefficient because you have to make 2 requests for each thumbnail.

A better solution based on the same HTTP Handler

Last week, I was working on different things around Office 365 and I discovered a better solution based on the same HTTP Handler.

It’s possible, rather than passing many parameters (siteId, webId, docId…), to pass only one parameter called ‘path’.

This parameter expects a value equal to the URL of the document/file for which you want to generate a thumbnail. To generate a preview, the URL should look like this :

https://tenant.sharepoint.com/portals/hub/_layouts/15/getpreview.ashx?path=https%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fcommunity%2FpVid%2FBiking%2520to%2520Work.mp4

In the sample above which generates a thumbnail for a video stored in an Office 365 video channel), you just have to encode the path of the file, and add it to the querystring for the ‘path‘ parameter.

I have tested with many file types (Word, Excel, PowerPoint, MP4…), stored in different containers (document libraries, video channels…) and it works for each of them.

For information, this solution is used by Delve to generate thumbnails for video files stored in Office 365 Video 😉

Delve - HomePage

Make your life easier with automatic storage management on SharePoint site collections

When you create a SharePoint site collection on your Office 365 tenant, by default you have to specify a storage quota which defines what’s the maximum amount of space you want to allocate to that site collection.

The quota is decreased from the storage pool assigned to your Office 365 tenant, depending on the number of licenses you purchased. By default the amount of available space is equal to 10 GB + 500 MB per user (but you can purchase additional storage space if necessary).

It’s pretty simple to use but there’s an issue with this model. Even if there’s no content stored in the site collection, the quota allocated is decreased from your storage pool. When the amount of available space is equal to zero, you won’t be able to create new site collections.

When you are an administrator of your Office 365 tenant, you are able to see all the site collections and the associated quotas from the SharePoint administration site (https://mytenant-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx) as you can see below.

Site Collection Storage Management - Before activation

But few months ago, Microsoft announced they were working on a new feature that would simplify the administration of storage space. That feature is available since few days on my tenants so let’s see how to activate it.

To achieve that goal, you have to be an Office 365 administrator and you have to go to the SharePoint admin center. On this site, just select the settings option from the left menu.

If the option is available on your tenant (the deployment on all Office 365 tenants may take some weeks), you should see a new option called Site Collection Storage Management as you can see on the following screenshot.

Site Collection Storage Management - Activation

To activate this new feature, you just need to select the Automatic option (by default it should be on Manual mode) and save your modifications.

If you go back on the screen which list all the site collections created on your Office 365 tenant, you should see that the columns named “storage limit” and “percent used” have disappeared.

Site Collection Storage Management - After activation

Now SharePoint will automatically manage the storage allocation, depending on the needs of each site collection. If your prefer to manage yourself the allocation, you can switch back to the manual mode to define quotas for each site collection.