Exemplo n.º 1
0
 public Stream GetFile(UppyFileInfo fileInfo)
 {
     using (var client = new FileRepositoryServiceClient())
     {
         return client.GetFile(fileInfo.FileName);
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// 上传文件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        FileRepositoryServiceClient client = new FileRepositoryServiceClient();

        //指定上传的文件名称,格式为:{服务器端分配给你的路径}/{自定义的文件名称(如果你很懒,可以直接向下面用FileUpload1.FileName)}
        szFilePath = szBasePath + "/" + FileUpload1.FileName;

        string szNewFilePath = "";

        bool bReturn = client.CreateImageFile(szFilePath, FileUpload1.PostedFile.InputStream, out szNewFilePath);

        if (bReturn)
        {
            /*
             * 上传成功后文件的http访问地址即为:上传目录的http根地址+分配给你的目录地址(order)+上传成功后传出的新文件名(szNewFilePath)
             * 如果文件上传成功,out参数传出的是返回的文件名称(是经过服务器端处理的),处理的原理是:如果服务器上不存在此文件,则原样输出,如果已经存在,则返回原文件名+一个相对唯一的时间字符串,
             */
            string szMsg = "上传成功,上传后的地址为:" + szShowBasePath + "/" + szBasePath + "/" + szNewFilePath;
            labMsg.Text = szMsg;
        }
        else
        {
            /*
             * 上传失败的话,out参数传出的就是错误信息,可供参考使用。
             */
            string szMsg = "上传失败,错误信息为" + szNewFilePath;
            labMsg.Text = szMsg;
        }
    }
Exemplo n.º 3
0
        private void InitializeServices()
        {
            client = new FileRepositoryServiceClient();
            var handler = new MetadataCallbackHandler(this);
            var context = new InstanceContext(handler);

            provider = new MetadataProviderClient(context);
        }
Exemplo n.º 4
0
        private static void CheckRemote()
        {
            var remoteAddress = ConfigurationManager.AppSettings["LiveUpdateServiceAddress"];

            if (!String.IsNullOrEmpty(remoteAddress))
            {
                //Inizializzo la connessione con il servizio WCF
                LiveUpdateClient = new FileRepositoryServiceClient();
            }
            // Altrimenti leggo solamente da file
        }
Exemplo n.º 5
0
        public List<UppyFileInfo> GetListFiels()
        {
            var listFiles = new List<UppyFileInfo>();

            using (var client = new FileRepositoryServiceClient())
            {
                var files = client.List(null);
                listFiles.AddRange(files.Select(storageFileInfo => new UppyFileInfo() { FileName = storageFileInfo.VirtualPath }));
            }

            return listFiles;
        }
Exemplo n.º 6
0
        public string GetFileToTemp(UppyFileInfo fileInfo)
        {
            using (var client = new FileRepositoryServiceClient())
            {
                var stream = client.GetFile(fileInfo.FileName);
                var pathFileSave = Path.Combine(Path.GetTempPath(), "UPPY" + Environment.TickCount + fileInfo.FileName);
                var writeFile = File.OpenWrite(pathFileSave);
                stream.CopyTo(writeFile);
                writeFile.Flush();
                writeFile.Close();

                return pathFileSave;
            }
        }
Exemplo n.º 7
0
        private UppyFileInfo PutFile(Stream stream, string fileName)
        {
            using (FileRepositoryServiceClient client = new FileRepositoryServiceClient())
            {
                var file = client.List().FirstOrDefault(x => x.VirtualPath == fileName);
                if (file == null)
                    client.PutFile(new FileUploadMessage() { DataStream = stream, VirtualPath = fileName });
            }

            UppyFileInfo uppyFileInfo = new UppyFileInfo();
            uppyFileInfo.FileName = fileName;

            return uppyFileInfo;
        }