a file based implementation. Takes a filename as it's base working mode
Inheritance: MediaSource
Example #1
0
        // retry one row. The userstate was removed from the retry queue before that call
        private bool RetryRow(UserState us) {
            if (us != null) {
                Trace.Indent();
                Trace.TraceInformation("Retrying a row, current position is: " + us.CurrentPosition + "for uri: " + us.ResumeUri);
                Trace.Unindent();
                if (us.CurrentPosition > 0 && us.ResumeUri != null) {
                    string contentType = MediaFileSource.GetContentTypeForFileName(us.Row.Cells[COLUMNINDEX_FILENAME].Value.ToString());
                    MediaFileSource mfs = new MediaFileSource(us.Row.Cells[COLUMNINDEX_FILENAME].Value.ToString(), contentType);

                    Stream s = mfs.GetDataStream();
                    s.Seek(us.CurrentPosition, SeekOrigin.Begin);

                    lock (this.flag) {
                        this.queue.Add(us);
                    }
                    us.Row.Cells[COLUMNINDEX_STATUS].Value = "Retrying (" + us.RetryCounter + ") - Last error was: " + us.Error;
                    ru.ResumeAsync(this.youTubeAuthenticator, us.ResumeUri, us.HttpVerb, s, contentType, us);

                    return true;
                }

                // else treat this as a new one, a resume from null
                return InsertVideo(us.Row, us.RetryCounter + 1);
            }
            return false;
        }
Example #2
0
        public void UploadFile(Stream file, string title, string mimeType)
        {
            if (String.IsNullOrEmpty(mimeType))
                throw new ArgumentException("mimeType is null or empty.", "mimeType");
            if (String.IsNullOrEmpty(title))
                throw new ArgumentException("title is null or empty.", "title");
            if (file == null)
                throw new ArgumentNullException("file", "file is null.");

            PhotoEntry entry = new PhotoEntry();
            entry.Title = new AtomTextConstruct(AtomTextConstructElementType.Title, title);
            MediaFileSource fileSource = new MediaFileSource(file, title, mimeType);
            entry.MediaSource = fileSource;

            _picasaService.Insert(new Uri(PhotoQuery.CreatePicasaUri(_picasaService.Credentials.Username, Id)),
                           entry);
        }