Skip to content

Commit

Permalink
feat(uploader)
Browse files Browse the repository at this point in the history
- implement right content type for private entities
  • Loading branch information
thiagocarvalhodev committed Sep 28, 2023
1 parent 70eab11 commit f29fe29
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ARFSFolderUploadMetatadata extends ARFSUploadMetadata {
required super.bundleTags,
});

// TODO: implement toJson
@override
Map<String, dynamic> toJson() {
return {
Expand Down
27 changes: 24 additions & 3 deletions packages/ardrive_uploader/lib/src/metadata_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ class ARFSUploadMetadataGenerator
id = const Uuid().v4();
}

String contentType;

if (arguments.isPrivate) {
contentType = 'application/octet-stream';
} else {
if (entity is IOFile) {
contentType = entity.contentType;
} else {
// folders and drives are always json
contentType = 'application/json';
}
}

if (entity is IOFile) {
ARFSUploadMetadataArgsValidator.validate(arguments, EntityType.file);

Expand All @@ -63,7 +76,7 @@ class ARFSUploadMetadataGenerator
parentFolderId: arguments.parentFolderId,
entityId: id,
entity: EntityType.file,
contentType: file.contentType,
contentType: contentType,
),
);

Expand Down Expand Up @@ -91,7 +104,7 @@ class ARFSUploadMetadataGenerator
parentFolderId: arguments.parentFolderId,
entityId: id,
entity: EntityType.folder,
contentType: 'application/json',
contentType: contentType,
),
);

Expand Down Expand Up @@ -120,12 +133,20 @@ class ARFSUploadMetadataGenerator
}) async {
final id = const Uuid().v4();

String contentType;

if (isPrivate) {
contentType = 'application/octet-stream';
} else {
contentType = 'application/json';
}

final tags = _tagsGenerator.generateTags(
ARFSTagsArgs(
isPrivate: isPrivate,
entityId: id,
entity: EntityType.drive,
contentType: 'application/json',
contentType: contentType,
),
);

Expand Down

0 comments on commit f29fe29

Please sign in to comment.