protected async override Task ExecuteOperation(IFileMetadataStore metadataStore, IFileSyncContext context) { MobileServiceFileMetadata metadata = await metadataStore.GetFileMetadataAsync(FileId); if (metadata != null) { IMobileServiceFileDataSource dataSource = await context.SyncHandler.GetDataSource(metadata); await context.MobileServiceFilesClient.UploadFileAsync(metadata, dataSource); await metadataStore.CreateOrUpdateAsync(metadata); } }
public async Task AddFileAsync(MobileServiceFile file) { var metadata = new MobileServiceFileMetadata { FileId = file.Id, FileName = file.Name, Length = file.Length, Location = FileLocation.Local, ContentMD5 = file.ContentMD5, ParentDataItemType = file.TableName, ParentDataItemId = file.ParentId }; await metadataStore.CreateOrUpdateAsync(metadata); var operation = new CreateMobileServiceFileOperation(Guid.NewGuid().ToString(), file.Id); await QueueOperationAsync(operation); NotifyFileOperationCompletion(file, FileOperationKind.Create, FileOperationSource.Local); }