Imaging.Download Method
Downloads the specified files (items) in a list on the current Web site.
Namespace: [Imaging Web service]
Web service reference: http://Site/_vti_bin/Imaging.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/ois/Download", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/ois/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/ois/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function Download ( _
strListName As String, _
strFolder As String, _
itemFileNames As String(), _
type As UInteger, _
fFetchOriginalIfNotAvailable As Boolean _
) As XmlNode
'Usage
Dim instance As Imaging
Dim strListName As String
Dim strFolder As String
Dim itemFileNames As String()
Dim type As UInteger
Dim fFetchOriginalIfNotAvailable As Boolean
Dim returnValue As XmlNode
returnValue = instance.Download(strListName, _
strFolder, itemFileNames, type, fFetchOriginalIfNotAvailable)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/ois/Download", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/ois/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/ois/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode Download(
string strListName,
string strFolder,
string[] itemFileNames,
uint type,
bool fFetchOriginalIfNotAvailable
)
Parameters
strListName
Type: System.StringThe name of the list within the current Web site.
strFolder
Type: System.StringThe relative path from the root of the list to the target folder.
itemFileNames
Type: []An array of the names of files (items) to download.
type
Type: System.UInt32The version of the files to download. Valid values: 0 for original, 1 for thumbnail, 2 for Web image.
fFetchOriginalIfNotAvailable
Type: System.BooleanIf this parameter is set to true and the requested version is not available for any reason, the original version is fetched.
Return Value
Type: System.Xml.XmlNode
A System.Xml.XmlDocument object that contains the following.
<Files xmlns="https://schemas.microsoft.com/sharepoint/soap/ois/">
<File name="itemFileNames[0]" found="false"/>
<File name="itemFileNames[1]" lastmodified="…">
Base64 encoded bytes of the file content
</File>
<File name="itemFileNames[2]" lastmodified="…"
originalDownloaded="true">
Base64 encoded bytes of the file content
</File>
.
.
.
</Files>
Exceptions
Exception | Condition |
---|---|
[0x1] | ListNotFound: The requested list is not found. |
[0x2] | IsNotLibrary: The requested list, although found, is not a picture library. |
[0x3] | ItemNotFound: The requested list item is not found. |
[0x4] | FolderNotFound: The requested folder is not found. |
[0x5] | InvalidArgument: One or more arguments are not valid. |
[0x6] | FileExists: The file already exists, and the user does not specify the overwrite option. |
Examples
The following example downloads the following image file from the "My Pictures" picture library: http://MyServer/sites/mynewsite/MyPictures/1/Red Figure2.gif.
Note
This code assumes that the site and picture library already exist, and that you have permissions on the server. If the site and the picture library do not exist, see the second example.
Dim imgws As New Web_Reference.Imaging()
imgws.Credentials = System.Net.CredentialCache.DefaultCredentials
imgws.Url = "http://MyServer/sites/mynewsite/_vti_bin/imaging.asmx"
Dim resdoc As New System.Xml.XmlDocument()
Dim resnode As System.Xml.XmlNode =
resdoc.CreateNode(System.Xml.XmlNodeType.Element, "Result", "")
Dim a(0) As String
a(0) = "Red Figure2.gif"
resnode = imgws.Download("My Pictures", "1", a, 0, True)
MessageBox.Show(resnode.ChildNodes(0).InnerText)
Web_Reference.Imaging imgws = new Web_Reference.Imaging();
imgws.Credentials = System.Net.CredentialCache.DefaultCredentials;
imgws.Url = "http://MyServer/sites/mynewsite/_vti_bin/imaging.asmx";
System.Xml.XmlDocument resdoc= new System.Xml.XmlDocument();
System.Xml.XmlNode resnode =
resdoc.CreateNode(System.Xml.XmlNodeType.Element,"Result","");
String[] a = new String[1];
a[0]="Red Figure2.gif";
resnode = imgws.Download("My Pictures","1",a,0,true);
MessageBox.Show(resnode.ChildNodes[0].InnerText);
This example shows how to create the site and picture library, and add the image "Red Figure2.gif" required in the preceding example.
Note
You must be a member of the Administrators site group on the Microsoft Windows SharePoint Services server to be able to add a reference to the Admin Web service and to perform the required actions.
Dim adminws As New Web_Reference.Admin()
adminws.Credentials = System.Net.CredentialCache.DefaultCredentials
Try
adminws.CreateSite("http://MyServer/sites/my2003site",
"My 2003 New Site", _
"Manage content and pictures for year 2003", 1033, "MPS#0",
"User_Alias", "Display_Name", "someone@example.com", "", "")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dim listsws As New Web_Reference.Lists()
listsws.Credentials = System.Net.CredentialCache.DefaultCredentials
listsws.Url = "http://MyServer/sites/mynewsite/_vti_bin/lists.asmx"
Try
listsws.AddList("My Pictures", "My personal pictures", 109)
Catch ex1 As Exception
MessageBox.Show(ex1.Message)
End Try
Dim imgws As New Web_Reference.Imaging()
imgws.Credentials = System.Net.CredentialCache.DefaultCredentials
imgws.Url = "http://MyServer/sites/mynewsite/_vti_bin/imaging.asmx"
Dim resdoc As New System.Xml.XmlDocument()
Dim resnode As System.Xml.XmlNode =
resdoc.CreateNode(System.Xml.XmlNodeType.Element, "Result", "")
Dim b As [Byte]() = System.Text.Encoding.Unicode.GetBytes
("R0lGODlhCQALAJEAAAoLBv///wAAAP///
yH5BAEAAAMALAAAAAAJAAsAAAIdlIdmETDAxBAxosm
CvE9fNU0K40Ae1ZBftq0t9xYAOw==")
imgws.Upload("My Pictures", "1", b, "Red Figure2.gif", True)
MessageBox.Show("Picture uploaded")
Dim a(0) As String
a(0) = "Red Figure1.gif"
resnode = imgws.Download("My Pictures", "1", a, 0, True)
MessageBox.Show(resnode.ChildNodes(0).InnerText)
Web_Reference.Admin adminws = new Web_Reference.Admin();
adminws.Credentials= System.Net.CredentialCache.DefaultCredentials;
try
{
adminws.CreateSite("http://MyServer/sites/my2003site",
"My 2003 New Site","Manage content and pictures for year
2003",1033,"MPS#0","User_Alias","Display_Name",
"someone@example.com","","");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
Web_Reference.Lists listsws = new Web_Reference.Lists();
listsws.Credentials = System.Net.CredentialCache.DefaultCredentials;
listsws.Url = "http://MyServer/sites/mynewsite/_vti_bin/lists.asmx";
try
{
listsws.AddList("My Pictures","My personal pictures",109);
}
catch(Exception ex1)
{
MessageBox.Show(ex1.Message);
}
Web_Reference.Imaging imgws = new Web_Reference.Imaging();
imgws.Credentials = System.Net.CredentialCache.DefaultCredentials;
imgws.Url = "http://MyServer/sites/mynewsite/_vti_bin/imaging.asmx";
System.Xml.XmlDocument resdoc= new System.Xml.XmlDocument();
System.Xml.XmlNode resnode =
resdoc.CreateNode(System.Xml.XmlNodeType.Element,"Result","");
Byte[] b =System.Text.Encoding.Unicode.GetBytes
("R0lGODlhCQALAJEAAAoLBv///wAAAP///
yH5BAEAAAMALAAAAAAJAAsAAAIdlIdmETDAxBAxosm
CvE9fNU0K40Ae1ZBftq0t9xYAOw==");
imgws.Upload("My Pictures","1",b,"Red Figure2.gif", true);
MessageBox.Show("Picture uploaded");
String[] a = new String[1];
a[0]="Red Figure1.gif";
resnode = imgws.Download("My Pictures","1",a,0,true);
MessageBox.Show(resnode.ChildNodes[0].InnerText);