This repository was archived by the owner on Oct 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFileStream.java
More file actions
60 lines (52 loc) · 1.73 KB
/
Copy pathFileStream.java
File metadata and controls
60 lines (52 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.vapi.api.core;
import java.io.InputStream;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.jetbrains.annotations.Nullable;
/**
* Represents a file stream with associated metadata for file uploads.
*/
public class FileStream {
private final InputStream inputStream;
private final String fileName;
private final MediaType contentType;
/**
* Constructs a FileStream with the given input stream and optional metadata.
*
* @param inputStream The input stream of the file content. Must not be null.
* @param fileName The name of the file, or null if unknown.
* @param contentType The MIME type of the file content, or null if unknown.
* @throws NullPointerException if inputStream is null
*/
public FileStream(InputStream inputStream, @Nullable String fileName, @Nullable MediaType contentType) {
this.inputStream = Objects.requireNonNull(inputStream, "Input stream cannot be null");
this.fileName = fileName;
this.contentType = contentType;
}
public FileStream(InputStream inputStream) {
this(inputStream, null, null);
}
public InputStream getInputStream() {
return inputStream;
}
@Nullable
public String getFileName() {
return fileName;
}
@Nullable
public MediaType getContentType() {
return contentType;
}
/**
* Creates a RequestBody suitable for use with OkHttp client.
*
* @return A RequestBody instance representing this file stream.
*/
public RequestBody toRequestBody() {
return new InputStreamRequestBody(contentType, inputStream);
}
}