2011-11-07 1 views
1

에서 이미지 검색 REST API를 사용하여 그림 라이브러리에서 이미지 (실제 파일이 아닌 URL)를 검색하는 것에 대한 제안이나 샘플을 찾고 있습니다.그림 라이브러리 - REST

입력 해 주셔서 감사합니다.

답변

1

작업 1 : 특정 사이트에 이미지 libs와의 목록을 얻기

public static XmlNode GetPicLibListingXML(string imagingServiceURL) 
{ 

       Imaging wsImaging = new Imaging(); 
       wsImaging.UseDefaultCredentials = true; 
       wsImaging.Url = imagingServiceURL; 
       XmlNode xnPicLibs = wsImaging.ListPictureLibrary(); 

       return xnPicLibs; 
    } 

샘플 반환 XML :

<Library name="{3C1D52F5-5387-490A-9A2D-A9C99A208C00}" title="Tech Images" guid="3c1d52f5-5387-490a-9a2d-a9c99a208c00" url="Tech Images" xmlns="http://schemas.microsoft.com/sharepoint/soap/ois/" /> 

작업 2 : 주어진 라이브러리에 이미지 목록

public static XmlNode GetImageFileListing(string imagingServiceURL, string imageFileLibraryName) 

{ 
     Imaging wsImaging = new Imaging(); 
     ImageInfo curImageInfo = new ImageInfo(); 
     wsImaging.UseDefaultCredentials = true; 
     wsImaging.Url = imagingServiceURL; 
     XmlNode xnListItems = wsImaging.GetListItems(imageFileLibraryName, ""); 

     return xnListItems; 
    } 

작업 3 : 이미지 다운로드

private const string ATTR_FILENAME = "name"; 

private const string FILENAMESPACEURI = "http://schemas.microsoft.com/sharepoint/soap/ois/"; 

public static bool DownloadImageFiles(string imagingServiceURL, string imageFileLibraryName, string[] fileNames, string saveToFolder) 

{ 
     Imaging wsImaging = new Imaging(); 
     wsImaging.UseDefaultCredentials = true; 
     wsImaging.Url = imagingServiceURL; 

     XmlElement parent = (XmlElement)wsImaging.Download(imageFileLibraryName, string.Empty, fileNames, 0, true); 

     XmlNodeList files = parent.GetElementsByTagName("File", FILENAMESPACEURI); 

     foreach (XmlNode file in files) 
     { 
      if (Directory.Exists(saveToFolder) == false) 
      { 
       Directory.CreateDirectory(saveToFolder); 
       } 

      byte[] fileBytes = Convert.FromBase64String(file.InnerText); 

      using (FileStream fs = File.OpenWrite(saveToFolder + file.Attributes[ATTR_FILENAME].Value)) 
      { 
        BinaryWriter writer = new BinaryWriter(fs); 
        writer.Write(fileBytes); 
        writer.Close(); 
       } 
      } 
      return true; 
     } 

참고 :

  • 이미징() 클래스 imagining.asmx하는 웹 참조입니다
  • 다운로드 전화는 기본적으로 XML 그렇게 요 유니드는 당신이 필요로하는 경우
  • 를 바이트 변환을 통해 그것을 실행 반환 MSDN에 밖으로에 이매진 웹 서비스 확인에 대한 참조 내용 :

http://msdn.microsoft.com/en-us/library/imaging.imaging.aspx

소스 :

http://gourangaland.wordpress.com/2008/05/30/using-the-moss-imaging-web-service-to-download-imagesimaging-asmx/

+0

감사 Tjassens이 - 당신이 어떤 기준을 제공 할 수 있을까요? – Spt2432

+0

여기에 가서 spt :) – Tjassens

+0

감사합니다. 나는 내일 이것을 시도 할 것이지만, 내가 찾고있는 것처럼 보인다. – Spt2432

관련 문제