Exemplo n.º 1
0
        public async Task <ActionResult> DownloadPDFAsync()
        {
            var client = new MinioStorage(objectStorageEndpoint, objectStorageAccessKey, objectStorageSecretKey, objectStorageSecure, objectStorageRegion);

            client.Connect();

            // Verify if exists Bucket and create if need
            if (!await client.BucketExistsAsync(objectStorageBucket))
            {
                await client.MakeBucketAsync(objectStorageBucket);
            }

            // Verify if exists file
            var azurePath = Server.MapPath("~/resources/Azure-Analytics-SQL cheat sheet.pdf");

            if (!await client.ObjectExistAsync(objectStorageBucket, StorageObjectAzure))
            {
                await client.PutObjectAsync(objectStorageBucket, StorageObjectAzure, azurePath, "application/pdf");
            }

            // Get 15 minutes URI
            var parameters = new Dictionary <string, string>
            {
                { "response-content-disposition", $"inline;filename=Azure-Analytics-SQL cheat sheet.pdf;" },
                { "response-content-type", "application/pdf" }
            };
            var tempUri = await client.PresignedGetObjectAsync(objectStorageBucket, StorageObjectAzure, 60, parameters);

            // Redirect to Url
            return(Redirect(tempUri));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> DownloadImageAsync()
        {
            var client = new MinioStorage(objectStorageEndpoint, objectStorageAccessKey, objectStorageSecretKey, objectStorageSecure, objectStorageRegion);

            client.Connect();

            // Verify if exists Bucket and create if need
            if (!await client.BucketExistsAsync(objectStorageBucket))
            {
                await client.MakeBucketAsync(objectStorageBucket);
            }

            // Verify if exists file
            var sfwarPath = Server.MapPath("~/resources/SFWar.png");

            if (!await client.ObjectExistAsync(objectStorageBucket, StorageObjectSfWar))
            {
                await client.PutObjectAsync(objectStorageBucket, StorageObjectSfWar, sfwarPath, "image/png");
            }

            // Get 15 minutes URI
            var parameters = new Dictionary <string, string>
            {
                { "response-content-disposition", $"inline;filename=SFWar.png;" },
                { "response-content-type", "image/png" }
            };
            var tempUri = await client.PresignedGetObjectAsync(objectStorageBucket, StorageObjectSfWar, 60, parameters);

            // Redirect to Url
            return(Redirect(tempUri));
        }