/// <summary> /// Updates an existing binary property value in the database and the blob storage. /// </summary> /// <param name="value">Binary data to update.</param> /// <param name="dataContext">Database accessor object.</param> /// <returns>A Task that represents the asynchronous operation.</returns> public async Task UpdateBinaryPropertyAsync(BinaryDataValue value, SnDataContext dataContext) { var blobProvider = ProviderSelector.GetProvider(value.Size); await DataProvider.UpdateBinaryPropertyAsync(blobProvider, value, dataContext); dataContext.NeedToCleanupFiles = true; }
/// <summary> /// Starts a chunked save operation on an existing content. It does not write any binary data /// to the storage, it only makes prerequisite operations - e.g. allocates a new slot in the storage. /// </summary> /// <param name="versionId">Content version id.</param> /// <param name="propertyTypeId">Binary property type id.</param> /// <param name="fullSize">Full size (stream length) of the binary value.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A Task that represents the asynchronous operation containing a token with /// all the information (db record ids) that identify a single entry in the blob storage.</returns> public Task <string> StartChunkAsync(int versionId, int propertyTypeId, long fullSize, CancellationToken cancellationToken) { var blobProvider = ProviderSelector.GetProvider(fullSize); return(DataProvider.StartChunkAsync(blobProvider, versionId, propertyTypeId, fullSize, cancellationToken)); }
/// <summary> /// Inserts a new binary record into the metadata database containing a new or an already existing file id, /// removing the previous record if the content is not new. /// </summary> /// <param name="value">Binary data to insert.</param> /// <param name="versionId">Content version id.</param> /// <param name="propertyTypeId">Binary property type id.</param> /// <param name="isNewNode">Whether this value belongs to a new or an existing node.</param> /// <param name="dataContext">Database accessor object.</param> /// <returns>A Task that represents the asynchronous operation.</returns> public Task InsertBinaryPropertyAsync(BinaryDataValue value, int versionId, int propertyTypeId, bool isNewNode, SnDataContext dataContext) { var blobProvider = ProviderSelector.GetProvider(value.Size); if (value.FileId > 0 && value.Stream == null) { return(DataProvider.InsertBinaryPropertyWithFileIdAsync(value, versionId, propertyTypeId, isNewNode, dataContext)); } else { return(DataProvider.InsertBinaryPropertyAsync(blobProvider, value, versionId, propertyTypeId, isNewNode, dataContext)); } }
/// <summary> /// Gets a provider based on the binary size and the available blob providers in the system. /// </summary> /// <param name="fullSize">Full binary length.</param> public IBlobProvider GetProvider(long fullSize) { return(ProviderSelector.GetProvider(fullSize)); }