Пример #1
1
        public async Task AddObjectToUploadQueueAsync(string bucketName, string key, string accessGrant, Stream stream, string identifier, CustomMetadata customMetadata)
        {
            await InitAsync().ConfigureAwait(false);

            var entry = new UploadQueueEntry();

            entry.AccessGrant    = accessGrant;
            entry.Identifier     = identifier;
            entry.BucketName     = bucketName;
            entry.Key            = key;
            entry.TotalBytes     = (int)stream.Length;
            entry.BytesCompleted = 0;
            if (customMetadata != null)
            {
                entry.CustomMetadataJson = JsonSerializer.Serialize(customMetadata);
            }

            var entryData = new UploadQueueEntryData();

            entryData.Bytes = new byte[stream.Length];
            stream.Read(entryData.Bytes, 0, (int)stream.Length);

            await _connection.RunInTransactionAsync((SQLiteConnection transaction) =>
            {
                transaction.Insert(entry);
                entryData.UploadQueueEntryId = entry.Id;
                transaction.Insert(entryData);
            });

            ProcessQueueInBackground();

            UploadQueueChangedEvent?.Invoke(QueueChangeType.EntryAdded, entry);
        }
Пример #2
0
        public async Task AddObjectToUploadQueueAsync(string bucketName, string key, string accessGrant, Stream stream, string identifier)
        {
            await InitAsync();

            var entry = new UploadQueueEntry();

            entry.AccessGrant    = accessGrant;
            entry.Identifier     = identifier;
            entry.BucketName     = bucketName;
            entry.Key            = key;
            entry.TotalBytes     = (int)stream.Length;
            entry.BytesCompleted = 0;

            await _connection.InsertAsync(entry);

            var entryData = new UploadQueueEntryData();

            entryData.UploadQueueEntryId = entry.Id;
            entryData.Bytes = new byte[stream.Length];
            var read = stream.Read(entryData.Bytes, 0, (int)stream.Length);

            await _connection.InsertAsync(entryData);

            ProcessQueueInBackground();

            UploadQueueChangedEvent?.Invoke(QueueChangeType.EntryAdded, entry);
        }
Пример #3
0
        private async Task RemoveEntry(UploadQueueEntry entry)
        {
            await _connection.Table <UploadQueueEntry>().DeleteAsync(e => e.Id == entry.Id);

            await _connection.Table <UploadQueueEntryData>().DeleteAsync(e => e.UploadQueueEntryId == entry.Id);

            UploadQueueChangedEvent?.Invoke(QueueChangeType.EntryRemoved, entry);
        }
Пример #4
0
        private async Task RemoveEntry(UploadQueueEntry entry)
        {
            await _connection.RunInTransactionAsync((SQLiteConnection transaction) =>
            {
                transaction.Table <UploadQueueEntry>().Delete(e => e.Id == entry.Id);
                transaction.Table <UploadQueueEntryData>().Delete(e => e.UploadQueueEntryId == entry.Id);
            });

            UploadQueueChangedEvent?.Invoke(QueueChangeType.EntryRemoved, entry);
        }
Пример #5
0
        public async Task AddObjectToUploadQueue(string bucketName, string key, string accessGrant, byte[] objectData, string identifier = null)
        {
            await InitAsync();

            var entry = new UploadQueueEntry();

            entry.AccessGrant = accessGrant;
            entry.Identifier  = string.IsNullOrWhiteSpace(identifier) ? Guid.NewGuid().ToString() : identifier;
            entry.BucketName  = bucketName;
            entry.Key         = key;
            entry.Bytes       = objectData;

            await _connection.InsertAsync(entry);
        }
Пример #6
0
 private void _uploadQueueService_UploadQueueChangedEvent(QueueChangeType queueChangeType, UploadQueueEntry entry)
 {
     throw new NotImplementedException();
 }