Exemplo n.º 1
0
        public byte[] GetMultimediaAsBytes(string tcmId)
        {
            byte[] buffer = null;
            try
            {
                this.OpenChannel();
                Stream       s = downloadChannel.DownloadBinaryContent(tcmId);
                MemoryStream m = new MemoryStream();
                int          b;
                do
                {
                    b = s.ReadByte();
                    m.WriteByte((byte)b);
                } while (b != -1);

                buffer = m.ToArray();
                return(buffer);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally {
                this.CloseChannel();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Upload a file to Tridion from a Tridion multimedia component or binary TBB
        /// </summary>
        /// <param name="item"><see cref="T:EGIT.CCIT.Tridion.CoreService.TcmUri"/> of the binary Tridion item.</param>
        /// <returns><see cref="T:System.IO.Stream" /> containing the binary data from Tridion</returns>
        public Stream DownloadFile(TcmUri item)
        {
            StreamDownloadClient client = null;

            try
            {
                client = DownloadClient;
                return(client.DownloadBinaryContent(item));
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == CommunicationState.Faulted)
                    {
                        client.Abort();
                    }
                    else
                    {
                        client.Close();
                    }
                }
            }
        }