S3BinaryCacheStore: Set Content-Type
This is necessary for serving log files to browsers.
This commit is contained in:
		
							parent
							
								
									8b1d65bebe
								
							
						
					
					
						commit
						45c70382ac
					
				
					 5 changed files with 25 additions and 13 deletions
				
			
		|  | @ -148,7 +148,7 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore | |||
|         : S3BinaryCacheStore(params) | ||||
|         , bucketName(bucketName) | ||||
|         , s3Helper(get(params, "aws-region", Aws::Region::US_EAST_1)) | ||||
|         , textCompression(get(params, "text-compression", "gzip")) | ||||
|         , textCompression(get(params, "text-compression", "")) | ||||
|         , logCompression(get(params, "log-compression", textCompression)) | ||||
|     { | ||||
|         diskCache = getNarInfoDiskCache(); | ||||
|  | @ -229,6 +229,7 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore | |||
|     } | ||||
| 
 | ||||
|     void uploadFile(const std::string & path, const std::string & data, | ||||
|         const std::string & mimeType, | ||||
|         const std::string & contentEncoding) | ||||
|     { | ||||
|         auto request = | ||||
|  | @ -236,6 +237,8 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore | |||
|             .WithBucket(bucketName) | ||||
|             .WithKey(path); | ||||
| 
 | ||||
|         request.SetContentType(mimeType); | ||||
| 
 | ||||
|         if (contentEncoding != "") | ||||
|             request.SetContentEncoding(contentEncoding); | ||||
| 
 | ||||
|  | @ -261,14 +264,15 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore | |||
|         stats.putTimeMs += duration; | ||||
|     } | ||||
| 
 | ||||
|     void upsertFile(const std::string & path, const std::string & data) override | ||||
|     void upsertFile(const std::string & path, const std::string & data, | ||||
|         const std::string & mimeType) override | ||||
|     { | ||||
|         if (path.find(".narinfo") != std::string::npos) | ||||
|             uploadFile(path, *compress(textCompression, data), textCompression); | ||||
|             uploadFile(path, *compress(textCompression, data), mimeType, textCompression); | ||||
|         else if (path.find("/log") != std::string::npos) | ||||
|             uploadFile(path, *compress(logCompression, data), logCompression); | ||||
|             uploadFile(path, *compress(logCompression, data), mimeType, logCompression); | ||||
|         else | ||||
|             uploadFile(path, data, ""); | ||||
|             uploadFile(path, data, mimeType, ""); | ||||
|     } | ||||
| 
 | ||||
|     void getFile(const std::string & path, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue