NAME

SBOM::CycloneDX::Attachment - Attachment utility

SYNOPSIS

use SBOM::CycloneDX::Attachment;

# Base64 content

$attachment = SBOM::CycloneDX::Attachment->new(
    content      => 'Y29uc29sZS5sb2coJ0dvb2RCeWUnKQ==',
    content_type => 'text/javascript'
);

# Plain content

$attachment = SBOM::CycloneDX::Attachment->new(
    content      => 'Copyright (C) Acme - All Rights Reserved',
    content_type => 'text/plain'
);

# File handler

open(my $fh, "<", "/path/LICENSE.md");

$attachment = SBOM::CycloneDX::Attachment->new(
    file => $fh
);

# File path

$attachment = SBOM::CycloneDX::Attachment->new(
    file => $fh
);

DESCRIPTION

SBOM::CycloneDX::Attachment is a attachment utility.

METHODS

SBOM::CycloneDX::Attachment inherits all methods from SBOM::CycloneDX::Base and implements the following new ones.

SBOM::CycloneDX::Attachment->new( %PARAMS )

Create a new attachment object.

Parameters:

  • file, File handle or file path

  • content, Plain content (text or BASE64 encoded)

  • content_type, content MIME/Type

NOTE: file and content cannot be used at the same time.

# Base64 content

$attachment = SBOM::CycloneDX::Attachment->new(
    content      => 'Y29uc29sZS5sb2coJ0dvb2RCeWUnKQ==',
    content_type => 'text/javascript'
);

# Plain content

$attachment = SBOM::CycloneDX::Attachment->new(
    content      => 'Copyright (C) Acme - All Rights Reserved',
    content_type => 'text/plain'
);

# File handler

open(my $fh, "<", "/path/LICENSE.md");

$attachment = SBOM::CycloneDX::Attachment->new(
    file => $fh
);

# File path

$attachment = SBOM::CycloneDX::Attachment->new(
    file => '/path/LICENSE.md'
);
$attachment->file

File handle or file path

$attachment->content_type

Specifies the format and nature of the data being attached, helping systems correctly interpret and process the content.

$attachment->content

Specifies the optional encoding the text is represented in.

$c->TO_JSON

Convert the attachment in JSON.

say encode_json($attachment);

# {
#   "content": "Y29uc29sZS5sb2coJ0dvb2RCeWUnKQ==",
#   "contentType": "text/javascript",
#   "encoding": "base64"
# }

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/giterlizzi/perl-SBOM-CycloneDX

git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git

AUTHOR

  • Giuseppe Di Terlizzi <gdt@cpan.org>

LICENSE AND COPYRIGHT

This software is copyright (c) 2025 by Giuseppe Di Terlizzi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.