Exemplo n.º 1
0
        public void UploadFile(string id, string upload_url, string json_settings)
        {
            if (this.files.ContainsKey(id)) {
                FileReference file = this.files[id];

                this.currentFile = file;
                file.Upload(upload_url, json_settings);
            }
        }
Exemplo n.º 2
0
        private void OnClick(object sender, MouseEventArgs e)
        {
            if (this.disabled) {
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            this.FireEvent("StartSelectFiles");

            try {
                dlg.Multiselect = this.multiselect;
                dlg.Filter = this.filter;

                if ((bool) dlg.ShowDialog()) {
                    foreach (FileInfo file in dlg.Files) {
                        FileReference uploadFile = new FileReference("u" + this.idCount++, file);

                        uploadFile.UploadChunkComplete += delegate(object up_sender, UploadEventArgs args) {
                            FileReference evtFile = (FileReference) up_sender;

                            this.FireEvent("UploadChunkSuccessful", evtFile.Id, args.Chunk, args.Chunks, args.Response);
                        };

                        uploadFile.UploadComplete += delegate(object up_sender, UploadEventArgs args) {
                            FileReference evtFile = (FileReference) up_sender;

                            this.FireEvent("UploadSuccessful", evtFile.Id, args.Response);
                        };

                        uploadFile.Error += delegate(object up_sender, ErrorEventArgs args) {
                            FileReference evtFile = (FileReference) up_sender;

                            this.FireEvent("UploadChunkError", evtFile.Id, args.Chunk, args.Chunks, args.Message);
                        };

                        uploadFile.Progress += delegate(object up_sender, ProgressEventArgs args) {
                            FileReference evtFile = (FileReference) up_sender;

                            this.FireEvent("UploadFileProgress", evtFile.Id, args.Loaded, args.Total);
                        };

                        this.FireEvent("SelectFile", uploadFile.Id, uploadFile.Name, uploadFile.Size);
                        this.files[uploadFile.Id] = uploadFile;
                    }

                    this.FireEvent("SelectSuccessful");
                } else
                    this.FireEvent("SelectCancelled");
            } catch (Exception ex) {
                this.FireEvent("SelectError", ex.Message);
            }
        }
Exemplo n.º 3
0
        public void UploadFile(string id, string upload_url, int chunk_size, int image_width, int image_height, int image_quality)
        {
            if (this.files.ContainsKey(id)) {
                FileReference file = this.files[id];

                this.currentFile = file;
                file.Upload(upload_url, chunk_size, image_width, image_height, image_quality);
            }
        }