All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.artipie.http.headers.ContentFileName Maven / Gradle / Ivy

There is a newer version: v1.17.16
Show newest version
/*
 * The MIT License (MIT) Copyright (c) 2020-2023 artipie.com
 * https://github.com/artipie/artipie/blob/master/LICENSE.txt
 */
package com.artipie.http.headers;

import java.net.URI;
import java.nio.file.Paths;

/**
 * Content-Disposition header for a file.
 *
 * @since 0.17.8
 */
public final class ContentFileName extends Header.Wrap {
    /**
     * Ctor.
     *
     * @param filename Name of attachment file.
     */
    public ContentFileName(final String filename) {
        super(
            new ContentDisposition(
                String.format("attachment; filename=\"%s\"", filename)
            )
        );
    }

    /**
     * Ctor.
     *
     * @param uri Requested URI.
     */
    public ContentFileName(final URI uri) {
        this(Paths.get(uri.getPath()).getFileName().toString());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy