Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // On récupére la valeur du text dans la TextBox
            String name = Request.QueryString["NomImage"];
            String path = Request.QueryString["Path"];

            // Si ce paramètre n'est pas nul
            if (name != null)
            {
                if (path != null)
                {
                    // Instanciation de la référence de service
                    ImageTransfertServiceReference.ImageTransfertClient imageTransfertService = new ImageTransfertServiceReference.ImageTransfertClient();
                    MemoryStream imageStream = new MemoryStream(lireFichier(path));
                    ImageTransfertServiceReference.ImageInfo info = new ImageTransfertServiceReference.ImageInfo();
                    info.ID      = name;
                    info.idAlbum = 1;
                    ImageTransfertServiceReference.ImageUploadRequest request = new ImageTransfertServiceReference.ImageUploadRequest();
                    request.ImageData = imageStream;
                    request.ImageInfo = info;
                    // Appel de notre web method
                    imageTransfertService.UploadImage(info, imageStream);
                    Session["transfert"] = "Transfert terminé";
                }
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // On récupére la valeur du paramètre ImageID passé dans l’URL
            String id = Request.QueryString["ImageID"];

            // Si ce paramètre n'est pas nul
            if (id != null)
            {
                // on récupére notre image là où il faut

                ImageTransfertServiceReference.ImageTransfertClient imageTransfertService = new ImageTransfertServiceReference.ImageTransfertClient();

                ImageTransfertServiceReference.ImageInfo info = new ImageTransfertServiceReference.ImageInfo();
                info.ID      = id;
                info.idAlbum = 1;

                ImageTransfertServiceReference.ImageDownloadResponse reponse = new ImageTransfertServiceReference.ImageDownloadResponse();

                // Appel de notre web method
                reponse.ImageData = imageTransfertService.DownloadImage(info);
                Stream image = reponse.ImageData;

                MemoryStream memStream = new MemoryStream();
                image.CopyTo(memStream);
                Byte[] bytes = memStream.ToArray();

                // et on crée le contenu de notre réponse à la requête HTTP
                // (ici un contenu de type image)
                Response.Buffer  = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
        }