Вопрос

I need to develop a C# custom webpart which allow users to download attachments from a sharepoint list. My webpart lists the attachments which the user has selected. Then, it must show him a link to download all the attachments as a zip file (similar to outlook.com feature) By doing some research (System.IO.Compression namespace), I found some ways to do it by creating a .zip file inside the server, but i have not found any way to send it to the user (and also, I would like to avoid saving the file in disk to just then send it).

PS: I`m using ApplicationPages [webmethods] and a javascript implements the user interface and call my webmethods.

Thanks !

Это было полезно?

Решение

What I would do in your situation:

  1. Create a custom action in the Files ribbon.
  2. When clicked, it redirecs the user to an application page of yours.
  3. The redirect is triggered from the custom action, e.g. from JavaScript code that also injects the Ids of current selected files in the query string.
  4. In the code of the application page, you can get the Ids from the query sring, retrieve requested documents from the doc lib, and zip them. All that being done from the OnLoad event.
  5. The application page actually does not display any UI element. Once the zip is ready as a memory stream, you send it to the Response body (with all required headers).
  6. As the page does not render any UI, the user should stay on the doc lib main page, and only get a prompt to download the file.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top