For an example application that integrates this process, see my FullstackOverview repo on GitHub. The code in this example is taken directly from this app.
This component allows you have a custom styled file upload element.
using System; | |
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; | |
namespace Foo { | |
// Implementation makes use of the IPropertyValidationFilter interface that allows | |
// control over whether the attribute (and its children, if relevant) need to be | |
// validated. | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | |
public class ConditionalValidationAttribute : Attribute, IPropertyValidationFilter { | |
public string OtherProperty { get; set; } |
/** | |
* Convert a Readable Stream to base64 string | |
* @param {ReadableStream} stream - a readable stream to convert in base64 string | |
* @returns {Promise} - Promise that resolve in a string containing the base64 | |
*/ | |
const streamToBase64 = (stream) => { | |
const concat = require('concat-stream') | |
const { Base64Encode } = require('base64-stream') | |
return new Promise((resolve, reject) => { |
const BlobToBase64 = function(blob){ | |
let blobUrl = URL.createObjectURL(blob); | |
return new Promise((resolve, reject) => { | |
let img = new Image(); | |
img.onload = () => resolve(img); | |
img.onerror = err => reject(err); | |
img.src = blobUrl; | |
}).then(img => { | |
URL.revokeObjectURL(blobUrl); |
using System; | |
using System.Linq; | |
using System.Reflection; | |
using Microsoft.Extensions.DependencyInjection; | |
public static class ServiceCollectionExtentions | |
{ | |
public static void AddAllTypes<T>(this IServiceCollection services | |
, Assembly[] assemblies | |
, bool additionalRegisterTypesByThemself = false |
using Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Security.Cryptography; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.IdentityModel.Tokens; |
request | |
response | |
app | |
req | |
res | |
originalUrl | |
state | |
_i18n | |
matched | |
router |
/* | |
*ngFor="let c of oneDimArray | sortBy:'asc'" | |
*ngFor="let c of arrayOfObjects | sortBy:'asc':'propertyName'" | |
*/ | |
import { Pipe, PipeTransform } from '@angular/core'; | |
import { orderBy } from 'lodash'; | |
@Pipe({ name: 'sortBy' }) | |
export class SortByPipe implements PipeTransform { |
import classNameProp from 'class-name-prop'; | |
import { useRouter } from 'next/router'; | |
import React from 'react'; | |
import styles from './RouteIndicator.module.css'; | |
const DONE_DURATION = 250; | |
export default function RouteIndicator() { | |
const router = useRouter(); |
For an example application that integrates this process, see my FullstackOverview repo on GitHub. The code in this example is taken directly from this app.
This component allows you have a custom styled file upload element.
import { Directive, EventEmitter, HostBinding, HostListener, Input, Output } from '@angular/core'; | |
// Angular Drag and Drop File | |
// | |
// Add this directive to an element to turn it into a dropzone | |
// for drag and drop of files. | |
// Example: | |
// | |
// <div (appDropZone)="onDrop($event)"></div> | |
// |