/// <summary> /// Creates a new file and adds it to the context without saving changes. /// </summary> /// <param name="file">The file to add.</param> /// <param name="ownerId">The unique user identifier from the data source for the user.</param> /// <returns> /// A <see cref="FileItem" /> instance if the operation was successful; otherwise <c>null</c>. /// </returns> protected virtual async Task <FileItem> AddAsync(FileItem file, int ownerId, CancellationToken cancellationToken) { await _services.Drive.CreateAsync(file, cancellationToken); file.OwnerId = ownerId; file.Slug = UriUtility.EncodeRandomUriToken(32); return(file); }
/// <summary> /// Generates a valid URL from the given URL. /// </summary> /// <param name="value">The value.</param> /// <returns> /// The generated URI. /// </returns> public virtual string Generate(string value) { return(UriUtility.EncodeRandomUriToken(32)); }