/// <summary>
        /// Returns the amount of bytes remaining that need to be pulled down from S3.
        /// </summary>
        /// <param name="filepath">The fully qualified path of the file.</param>
        /// <returns></returns>
        static async Task<ByteRange> ByteRangeRemainingForDownloadAsync(string filepath)
        {
            /*
             * Initialize the ByteRange as the whole file.
             * long.MaxValue works regardless of the size because
             * S3 will stop sending bits if you specify beyond the
             * size of the file anyways.
             */
            ByteRange byteRange = new ByteRange(0, long.MaxValue);

            var file = await PCLStorage.FileSystem.Current.GetFileFromPathAsync(filepath).ConfigureAwait(false);
            if (file != null)
            {
                using (var stream = await file.OpenAsync(PCLStorage.FileAccess.Read).ConfigureAwait(false))
                {
                    byteRange.Start = stream.Length;
                }
            }

            return byteRange;
        }
Example #2
0
        /// <summary>
        /// Returns the amount of bytes remaining that need to be pulled down from S3.
        /// </summary>
        /// <param name="filepath">The fully qualified path of the file.</param>
        /// <returns></returns>
        static ByteRange ByteRangeRemainingForDownload(string filepath)
        {
            /*
             * Initialize the ByteRange as the whole file.
             * long.MaxValue works regardless of the size because
             * S3 will stop sending bits if you specify beyond the
             * size of the file anyways.
             */
            ByteRange byteRange = new ByteRange(0, long.MaxValue);

            if (File.Exists(filepath))
            {
                FileInfo info = new FileInfo(filepath);
                byteRange.Start = info.Length;
            }

            return byteRange;
        }