public VideoItemImage(MobileServiceFile file, VideoItem todoItem) { Name = file.Name; File = file; FileHelper.GetLocalFilePathAsync(todoItem.Id, file.Name).ContinueWith(x => this.Uri = x.Result); }
public async Task AddAsync(MobileServiceFile file, Stream source) { using (var target = await this.fileSystem.CreateAsync(GetFileName(file))) { await source.CopyToAsync(target); } }
internal async Task DeleteImage(Monkey monkey, MobileServiceFile file) { // FILES: Deleting file await this.monkeyTable.DeleteFileAsync(file); // "Touch" the record to mark it as updated await this.monkeyTable.UpdateAsync(monkey); }
internal async Task DeleteImage(TodoItem todoItem, MobileServiceFile file) { // FILES: Deleting file await this.todoTable.DeleteFileAsync(file); // "Touch" the record to mark it as updated await this.todoTable.UpdateAsync(todoItem); }
public void ChangedFileMetadataIsUpdated() { MobileServiceFileMetadata metadata = this.testMetadata.FirstOrDefault(f => string.Compare(f.FileId, "updated-123") == 0); MobileServiceFile file = this.testFiles.FirstOrDefault(f => string.Compare(f.Id, "updated-123") == 0); Assert.Equal(file.ContentMD5, metadata.ContentMD5); Assert.Equal(file.LastModified, metadata.LastModified); }
private Task DownloadFileAsync(MobileServiceFile file) { lock (currentDownloadTaskLock) { return(currentDownloadTask = currentDownloadTask.ContinueWith(x => DoFileDownloadAsync(file)).Unwrap()); } }
internal async Task DownloadFileAsync(MobileServiceFile file) { var todoItem = await todoTable.LookupAsync(file.ParentId); Debug.WriteLine("++ Downloading file: " + todoItem.Name); IPlatform platform = DependencyService.Get <IPlatform>(); await platform.DownloadFileAsync(this.todoTable, file); }
public void DeleteLocalFile(MobileServiceFile file) { string localPath = GetLocalFilePath(file.ParentId, file.Name); if (File.Exists(localPath)) { File.Delete(localPath); } }
private static MobileServiceFile GetFileReference(Models.Image image, string param) { var toDownload = new MobileServiceFile(image.File.Id, image.File.Name, image.File.TableName, image.File.ParentId) { StoreUri = image.File.StoreUri.Replace("lg", param) }; return(toDownload); }
internal Task DownloadFileAsync(MobileServiceFile file) { // should only download one file at a time, since it's possible to get duplicate notifications for the same file // ContinueWith is used along with Wait() so that only one thread downloads at a time lock (currentDownloadTaskLock) { return(currentDownloadTask = currentDownloadTask.ContinueWith(x => DoFileDownloadAsync(file)).Unwrap()); } }
public AddNewFileScenario() { this.inputFile = new MobileServiceFile("id", "name", "tableName", "parentId"); this.inputFile.ContentMD5 = "md5"; this.inputFile.Length = 12345; this.inputFile.LastModified = new DateTimeOffset(new DateTime(2015, 1, 1, 1, 1, 1)); SyncContext.AddFileAsync(inputFile).Wait(); }
internal async Task DownloadFileAsync(MobileServiceFile file) { var todoItem = await todoTable.LookupAsync(file.ParentId); IPlatform platform = DependencyService.Get <IPlatform>(); string filePath = await FileHelper.GetLocalFilePathAsync(file.ParentId, file.Name); await platform.DownloadFileAsync(this.todoTable, file, filePath); }
public TodoItemImageViewModel(MobileServiceFile file, TodoItem todoItem, Action <TodoItemImageViewModel> deleteHandler) { this.deleteHandler = deleteHandler; this.uri = FileHelper.GetLocalFilePath(todoItem.Id, file.Name); this.name = file.Name; this.File = file; InitializeCommands(); }
public TodoItemImage(MobileServiceFile file, TodoItem item) { Name = file.Name; File = file; todoitem = item; fileProvider = DependencyService.Get <IFileProvider>(); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed InitializeUriAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action != FileSynchronizationAction.Delete) { var filepath = _fileHelper.GetLocalFilePath(file.ParentId, file.Name); if (!_fileHelper.Exists(filepath)) { await _fileHelper.DownloadFileAsync(_categoriesTable, file, filepath); } } }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action == FileSynchronizationAction.Delete) { await FileHelper.DeleteLocalFileAsync(file); } else { // Create or update. We're aggressively downloading all files. await this.todoItemManager.DownloadFileAsync(file); } }
public async Task DeleteFileAsync(MobileServiceFile file) { try { await AzureTable.DeleteFileAsync(file); } catch (Exception exception) { Debug.WriteLine(exception.Message); } }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action == FileSynchronizationAction.Delete) { fileHelper.DeleteLocalFile(file); } else // Create or update. We're aggressively downloading all files. { await this.fileSyncHelper.DownloadFileAsync(todoTable, file, fileHelper.GetLocalFilePath(file.ParentId, file.Name)); } }
private async void AddImage(object obj) { var mediaPicker = new MediaPicker(App.UIContext); var photo = await mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions()); MobileServiceFile file = await this.itemManager.AddImage(this.todoItem, photo.Path); var image = new TodoItemImageViewModel(file, this.todoItem, DeleteImage); this.images.Add(image); }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action == FileSynchronizationAction.Delete) { await fileProvider.DeleteLocalFileAsync(file); } else { await cloudService.DownloadItemFileAsync(file); } }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action == FileSynchronizationAction.Delete) { // You can remove images for delete items here } else { await DownloadFileAsync(file); } }
internal async Task <MobileServiceFile> AddImage(TodoItem todoItem, string imagePath) { string targetPath = FileHelper.CopyTodoItemFile(todoItem.Id, imagePath); // FILES: Creating/Adding file MobileServiceFile file = await this.todoTable.AddFileAsync(todoItem, Path.GetFileName(targetPath)); // "Touch" the record to mark it as updated await this.todoTable.UpdateAsync(todoItem); return(file); }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action == FileSynchronizationAction.Delete) { fileHelper.DeleteLocalFile(file); } else { var filepath = fileHelper.GetLocalFilePath(file.ParentId, file.Name); await this.fileSyncHelper.DownloadFileAsync(couponTable, file, filepath); } }
public async Task DeleteLocalFileAsync(MobileServiceFile fileName) { string localPath = await GetLocalFilePathAsync(fileName.ParentId, fileName.Name); var checkExists = await FileSystem.Current.LocalStorage.CheckExistsAsync(localPath); if (checkExists == ExistenceCheckResult.FileExists) { var file = await FileSystem.Current.LocalStorage.GetFileAsync(localPath); await file.DeleteAsync(); } }
public async void OnAdd(object sender, EventArgs e) { IPlatform mediaProvider = DependencyService.Get <IPlatform>(); string sourceImagePath = await mediaProvider.TakePhotoAsync(App.UIContext); if (sourceImagePath != null) { MobileServiceFile file = await this.manager.AddImage(this.videoItem, sourceImagePath); var image = new VideoItemImage(file, this.videoItem); this.Images.Add(image); } }
internal async Task <MobileServiceFile> AddImage(Monkey monkey, string imagePath) { string targetPath = fileHelper.CopyFileToAppDirectory(monkey.Id, imagePath); // FILES: Creating/Adding file MobileServiceFile file = await this.monkeyTable.AddFileAsync(monkey, Path.GetFileName(targetPath)); // "Touch" the record to mark it as updated await this.monkeyTable.UpdateAsync(monkey); return(file); }
public MobileServiceFileSystemFile(MobileServiceFile file, string physicalPath) { ContentMD5 = file.ContentMD5; Id = file.Id; LastModified = file.LastModified; Length = file.Length; Metadata = file.Metadata; Name = file.Name; ParentId = file.ParentId; StoreUri = file.StoreUri; TableName = file.TableName; PhysicalPath = physicalPath; }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { switch(action) { case FileSynchronizationAction.Create: case FileSynchronizationAction.Update: var stream = await client.GetFileAsync(file); await localStorage.AddAsync(file, stream); break; case FileSynchronizationAction.Delete: await localStorage.DeleteAsync(file); break; } }
public async Task DownloadFileAsync <T>(IMobileServiceSyncTable <T> table, MobileServiceFile file) { var path = await FileHelper.GetLocalFilePathAsync(file.ParentId, file.Name); var folder = Path.GetDirectoryName(path); var storageFolder = await StorageFolder.GetFolderFromPathAsync(folder); if (await storageFolder.TryGetItemAsync(file.Name) == null) { await storageFolder.CreateFileAsync(file.Name); } await table.DownloadFileAsync(file, path); }
public static MobileServiceExpressFile FromFile(MobileServiceFile file) { return new MobileServiceExpressFile { ContentMD5 = file.ContentMD5, Id = file.Id, LastModified = file.LastModified, Length = file.Length, Metadata = file.Metadata, Name = file.Name, ParentId = file.ParentId, StoreUri = file.StoreUri, TableName = file.TableName }; }
/// <summary> /// Delete an existing mobile apps associated file /// </summary> /// <param name="file">The file to delete</param> /// <returns>Task (Async)</returns> public async Task DeleteLocalFileAsync(MobileServiceFile file) { string localPath = await GetLocalFilePathAsync(file.ParentId, file.Name); var storageFolder = await StorageFolder.GetFolderFromPathAsync(Path.GetDirectoryName(localPath)); try { var storageFile = await storageFolder.GetFileAsync(Path.GetFileName(localPath)); await storageFile.DeleteAsync(); } catch (FileNotFoundException) { } // UnauthorizedAccessException is still thrown, but should never happen }
private async Task DoFileDownloadAsync(MobileServiceFile file) { var filepath = await FileHelper.GetLocalFilePathAsync(file.ParentId); var storagePath = FileSystem.Current.LocalStorage.Path; var fullpath = Path.Combine(storagePath, filepath); using (System.IO.Stream stream = File.Create(fullpath)) { } await saleItemsTable.DownloadFileAsync(file, fullpath); await SaleItemDataService.Instance.MobileService.EventManager .PublishAsync(new FileDownloadedEvent { Name = file.ParentId }); }
public async Task ProcessFileSynchronizationAction(MobileServiceFile file, FileSynchronizationAction action) { if (action == FileSynchronizationAction.Delete) { await FileHelper.DeleteLocalFileAsync(file, theApp.DataFilesPath); } else // Create or update. We're aggressively downloading all files. { Trace.WriteLine(string.Format("File - storeUri: {1}", file.Name, file.StoreUri)); if (file.StoreUri.Contains("lg")) { await this.theApp.DownloadFileAsync(file); } } }
public static MobileServiceFileMetadata FromFile(MobileServiceFile file) { return(new MobileServiceFileMetadata { FileId = file.Id, FileName = file.Name, ContentMD5 = file.ContentMD5, LastModified = file.LastModified, Length = file.Length, ParentDataItemId = file.ParentId, ParentDataItemType = file.TableName, FileStoreUri = file.StoreUri, PendingDeletion = false, Metadata = file.Metadata != null?JsonConvert.SerializeObject(file.Metadata) : null }); }
/// <summary> /// Convert a <see cref="MobileServiceFile"/> into a <see cref="MobileServiceFileMetadata"/> /// </summary> /// <param name="file">The <see cref="MobileServiceFile"/> instance</param> /// <returns>An equivalent <see cref="MobileServiceFileMetadata"/> instance</returns> public static MobileServiceFileMetadata FromFile(MobileServiceFile file) { return new MobileServiceFileMetadata { FileId = file.Id, FileName = file.Name, ContentMD5 = file.ContentMD5, LastModified = file.LastModified, Length = file.Length, ParentDataItemId = file.ParentId, ParentDataItemType = file.TableName, FileStoreUri = file.StoreUri, PendingDeletion = false, Metadata = file.Metadata != null ? JsonConvert.SerializeObject(file.Metadata) : null }; }
public async Task DeleteAsync(MobileServiceFile file) { await this.fileSystem.DeleteAsync(GetFileName(file)); }
public async Task<Stream> GetFileAsync(MobileServiceFile file) { return await LocalStorage.GetAsync(file); }
public async Task<MobileServiceExpressFile> AddFileAsync(MobileServiceFile file, Stream stream) { await base.AddFileAsync(file); await LocalStorage.AddAsync(file, stream); return LocalStorage.AttachMetadata(file); }
public new async Task DeleteFileAsync(MobileServiceFile file) { await base.DeleteFileAsync(file); await LocalStorage.DeleteAsync(file); }
public async Task DownloadFileToStreamAsync(MobileServiceFile file, Stream stream, StorageToken storageToken) { CloudBlockBlob blob = await GetBlobReference(storageToken, file.Name); await blob.DownloadToStreamAsync(stream); }
public async Task<Stream> GetFileAsync(MobileServiceFile file, StorageToken token) { CloudBlockBlob blob = await GetBlobReference(token, file.Name); return await blob.OpenReadAsync(); }
public async Task<Stream> GetAsync(MobileServiceFile file) { return await this.fileSystem.OpenReadAsync(GetFileName(file)); }
public FileOperationCompletedEvent(MobileServiceFile file, FileOperationKind operationKind, FileOperationSource source) { File = file; Kind = operationKind; Source = source; }
public MobileServiceExpressFile AttachMetadata(MobileServiceFile file) { return new MobileServiceFileSystemFile(file, fileSystem.GetFullFilePath(GetFileName(file))); }
private string GetFileName(MobileServiceFile file) { return Path.Combine(string.Format("{0}-{1}-{2}", file.TableName, file.ParentId, file.Name)); }