Пример #1
0
 public PictureController(IOptions <FileUploadOptions> fileOptions, IPictureRepository pictureRepository, IExperienceRepository experienceRepository, ILogger logger, IMapper mapper)
 {
     _fileOptions          = fileOptions.Value;
     _pictureRepository    = pictureRepository;
     _experienceRepository = experienceRepository;
     _logger = logger;
     _mapper = mapper;
 }
Пример #2
0
 public FileService(IPrincipal user, IAuthorizationService authService, FileUploadOptions fileOptions, PlayerContext context, IMapper mapper, ITeamService teamService)
 {
     _user = user as ClaimsPrincipal;
     _authorizationService = authService;
     _fileUploadOptions    = fileOptions;
     _context     = context;
     _mapper      = mapper;
     _teamService = teamService;
 }
 public static IServiceCollection AddFileUpload(
     this IServiceCollection services,
     FileUploadOptions options
     )
 {
     return(services
            .AddScoped <IFileUploadHandler, FileUploadHandler>()
            .AddSingleton <FileUploadOptions>(_ => options)
            .AddSingleton <IFileUploadMonitor, FileUploadMonitor>());
 }
Пример #4
0
 public DocumentController(
     ILogger <AdminController> logger,
     IIdentityResolver identityResolver,
     WorkspaceService workspaceService,
     FileUploadOptions uploadOptions,
     IHubContext <TopologyHub, ITopoEvent> hub
     ) : base(logger, identityResolver)
 {
     _uploadOptions    = uploadOptions;
     _workspaceService = workspaceService;
     _hub = hub;
 }
Пример #5
0
        public async Task UploadFiles()
        {
            var messagingProfileService = new MessagingProfileService();
            var id       = messagingProfileService.List().Data.First().Id;
            var fOptions = new FileUploadOptions {
                Bill = "testdata", Loa = "testdata"
            };
            var result = await orderService.UploadFileAsync(id.ToString(), fOptions);

            Console.WriteLine("Number Orders Files Uploaded: ");
            Console.WriteLine(JsonConvert.SerializeObject(result));
        }
Пример #6
0
 /// <inheritdoc />
 public async Task AddOrReplaceFileToTransactionAsync(
     string filePath,
     string transactionId,
     string fileId,
     FileUploadOptions uploadOptions,
     CancellationToken cancellationToken = default)
 {
     await retryPolicy
     .ExecuteAsync(
         ct => client.AddOrReplaceFileToTransactionAsync(
             filePath,
             transactionId,
             fileId,
             uploadOptions,
             ct),
         cancellationToken);
 }
Пример #7
0
 public AdminController(
     ILogger <AdminController> logger,
     IIdentityResolver identityResolver,
     ChatService chatService,
     IHubContext <TopologyHub, ITopoEvent> hub,
     TransferService transferSvc,
     FileUploadOptions fileUploadOptions,
     JanitorService janitor,
     HubCache hubCache
     ) : base(logger, identityResolver)
 {
     _chatService   = chatService;
     _transferSvc   = transferSvc;
     _uploadOptions = fileUploadOptions;
     _hub           = hub;
     _hubCache      = hubCache;
     _janitor       = janitor;
 }
Пример #8
0
        /// <summary>
        /// 配置文件上传的参数
        /// </summary>
        /// <returns></returns>
        public static IServiceCollection UseFileOptions(this IServiceCollection services, Action <FileUploadOptions> options)
        {
            FileUploadOptions fileUploadOptions = new FileUploadOptions();

            options?.Invoke(fileUploadOptions);
            if (string.IsNullOrWhiteSpace(fileUploadOptions.UploadFilePath))
            {
                throw new ArgumentNullException("参数不能为空:" + nameof(fileUploadOptions.UploadFilePath));
            }
            if (fileUploadOptions != null && !string.IsNullOrWhiteSpace(fileUploadOptions.UploadFilePath))
            {
                if (!Directory.Exists(fileUploadOptions.UploadFilePath))
                {
                    Directory.CreateDirectory(fileUploadOptions.UploadFilePath);
                }
            }
            //注入文件操作类
            services.AddSingleton <IFileHelper, FileHelper>();
            services.AddSingleton <IUploadFile, UploadFile>();
            services.AddTransient <Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider>();
            return(services.Configure(options));
        }
 public static IServiceCollection AddFileUploadService(this IServiceCollection services, FileUploadOptions options)
 {
     return(services.AddTransient <IFileUpload>(factory => new FileUploadService(options)));
 }
Пример #10
0
        public async Task <string> UploadFileAsync(string filePath, IMessageChannel channel = null, FileUploadOptions options = FileUploadOptions.None)
        {
            if (channel is null)
            {
                ulong serverId  = config.ScratchServer;
                ulong channelId = config.ScratchChannel;

                if (serverId <= 0 || channelId <= 0)
                {
                    throw new Exception("Cannot upload images because no scratch server/channel has been specified in the configuration file.");
                }

                IGuild guild = client.GetGuild(serverId);

                if (guild is null)
                {
                    throw new Exception("Cannot upload images because the scratch server is inaccessible.");
                }

                channel = await guild.GetTextChannelAsync(channelId);

                if (channel is null)
                {
                    throw new Exception("Cannot upload images because the scratch channel is inaccessible.");
                }
            }

            return(await DiscordUtilities.UploadFileAsync(channel, filePath, options));
        }