Skip to content

Commit bf4336f

Browse files
Merge pull request #7431 from nimrod-becker/backport_to_5_13
[Backport to 5.13] nsfs: handle content type
2 parents 09c9170 + 37390bf commit bf4336f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/native/fs/fs_napi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const static std::map<std::string, int> flags_to_case = {
159159
};
160160

161161
const static std::vector<std::string> GPFS_XATTRS{ GPFS_ENCRYPTION_XATTR_NAME };
162-
const static std::vector<std::string> USER_XATTRS{ "user.content_md5", "user.version_id", "user.prev_version_id", "user.delete_marker"};
162+
const static std::vector<std::string> USER_XATTRS{ "user.content_type", "user.content_md5", "user.version_id", "user.prev_version_id", "user.delete_marker"};
163163

164164
struct Entry
165165
{

src/sdk/namespace_fs.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const buffers_pool = new buffer_utils.BuffersPool({
3838

3939
const XATTR_USER_PREFIX = 'user.';
4040
// TODO: In order to verify validity add content_md5_mtime as well
41+
const XATTR_CONTENT_TYPE = XATTR_USER_PREFIX + 'content_type';
4142
const XATTR_MD5_KEY = XATTR_USER_PREFIX + 'content_md5';
4243
const XATTR_VERSION_ID = XATTR_USER_PREFIX + 'version_id';
4344
const XATTR_PREV_VERSION_ID = XATTR_USER_PREFIX + 'prev_version_id';
@@ -825,6 +826,10 @@ class NamespaceFS {
825826
// handle xattr
826827
if (!params.copy_source || !params.xattr_copy) {
827828
fs_xattr = to_fs_xattr(params.xattr);
829+
if (params.content_type) {
830+
fs_xattr = fs_xattr || {};
831+
fs_xattr[XATTR_CONTENT_TYPE] = params.content_type;
832+
}
828833
if (digest) {
829834
const { md5_b64, key, bucket, upload_id } = params;
830835
if (md5_b64) {
@@ -1473,14 +1478,15 @@ class NamespaceFS {
14731478
const etag = this._get_etag(stat);
14741479
const encryption = this._get_encryption_info(stat);
14751480
const version_id = return_version_id && this._is_versioning_enabled() && this._get_version_id_by_xattr(stat);
1481+
const content_type = stat.xattr[XATTR_CONTENT_TYPE] || mime.getType(key) || 'application/octet-stream';
14761482
return {
14771483
obj_id: etag,
14781484
bucket,
14791485
key,
14801486
etag,
14811487
size: stat.size,
14821488
create_time: stat.mtime.getTime(),
1483-
content_type: mime.getType(key) || 'application/octet-stream',
1489+
content_type,
14841490
// temp:
14851491
version_id: version_id,
14861492
is_latest: true,

0 commit comments

Comments
 (0)