public async static Task UploadFileAsync <T>(this IMobileServiceSyncTable <T> table, MobileServiceFile file, string filePath)
        {
            IMobileServiceFileDataSource dataSource = new PathMobileServiceFileDataSource(filePath);

            MobileServiceFileMetadata metadata = MobileServiceFileMetadata.FromFile(file);

            IFileSyncContext context = table.MobileServiceClient.GetFileSyncContext();

            await context.MobileServiceFilesClient.UploadFileAsync(metadata, dataSource);
        }
        public Task <IMobileServiceFileDataSource> GetDataSource(MobileServiceFileMetadata metadata)
        {
#if PORTABLE || WINDOWS_PHONE
            throw new ArgumentException("This functionality is not implemented in this version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.");
#else
            var source = new PathMobileServiceFileDataSource(GetFileFullPath(metadata.ParentDataItemId, metadata.FileName)) as IMobileServiceFileDataSource;

            return(Task.FromResult(source));
#endif
        }
        public Task <IMobileServiceFileDataSource> GetDataSource(Microsoft.WindowsAzure.MobileServices.Files.Metadata.MobileServiceFileMetadata metadata)
        {
            IMobileServiceFileDataSource source = new PathMobileServiceFileDataSource(FileHelper.GetLocalFilePath(metadata.ParentDataItemId, metadata.FileName));

            return(Task.FromResult(source));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Uploads a <paramref name="file"/> from a local file specified in the <paramref name="filePath"/>
        /// </summary>
        /// <typeparam name="T">The type of the instances in the table.</typeparam>
        /// <param name="table">The table instance that contains the record associated with the <see cref="MobileServiceFile"/>.</param>
        /// <param name="file">The <see cref="MobileServiceFile"/> instance.</param>
        /// <param name="filePath">The path of the file to be uploaded.</param>
        /// <returns>A <see cref="Task"/> that completes when the upload has finished.</returns>
        public async static Task UploadFileAsync <T>(this IMobileServiceTable <T> table, MobileServiceFile file, string filePath)
        {
            IMobileServiceFileDataSource dataSource = new PathMobileServiceFileDataSource(filePath);

            await table.UploadFileAsync(file, dataSource);
        }