public async Task RevokePublishAsync(string appId, string objectId) { ImageElement element = _repository.FindImageElementById(objectId); if (element == null) { return; } ServiceAppStorageRelation rel = await _storageService.FindStorageRelationByIdAsync( appId, element.StorageId); if (rel == null) { throw new StaticObjectsException( $"APPID {appId} is not allowed to use STORAGE {element.StorageId}", null) { Code = (int)System.Net.HttpStatusCode.MethodNotAllowed, }; } Storage storage = _storageService.FindStorageById(element.StorageId); await _storageService.RevokePublishAsync(storage, element); await _repository.RevokePublishAsync(element); }
public async Task <ImageElement> UploadImgAsync(string appId, Stream stream, string storageId, string objectId, string extension, string filePath, string srcFileName) { ServiceAppStorageRelation rel = await _storageService.FindStorageRelationByIdAsync( appId, storageId); if (rel == null) { throw new StaticObjectsException( $"APPID {appId} is not allowed to use STORAGE {storageId}", null) { Code = (int)System.Net.HttpStatusCode.MethodNotAllowed, }; } ImageElement element = new ImageElement() { StorageId = storageId, Extension = extension, CTIME = DateTime.Now, FilePath = filePath, IsPublished = false, ObjectId = objectId, SrcFileName = srcFileName, StoreWithSrcFileName = rel.StoreWithSrcFileName.GetValueOrDefault(), }; var entity = _repository.GetImageElementById(objectId); if (entity != null) { entity.UTIME = DateTime.Now; entity.StorageId = storageId; entity.Extension = extension; entity.FilePath = filePath; entity.SrcFileName = srcFileName; element = entity; } Storage storage = _storageService.FindStorageById(element.StorageId); await _storageService.UploadFileAsync(storage, element, stream); await _repository.UpsertElementAsync(element); return(element); }