forked from Dreampie/Resty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
resty-client/src/main/java/cn/dreampie/client/ClientFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cn.dreampie.client; | ||
|
||
import cn.dreampie.common.util.Checker; | ||
import cn.dreampie.common.util.HttpTyper; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Created by Dreampie on 16/1/5. | ||
*/ | ||
public class ClientFile { | ||
private String name; | ||
private String mimeType; | ||
private InputStream inputStream; | ||
|
||
public ClientFile(String filepath) throws FileNotFoundException { | ||
this(new File(filepath)); | ||
} | ||
|
||
public ClientFile(File file) throws FileNotFoundException { | ||
this.name = file.getName(); | ||
this.mimeType = HttpTyper.getContentTypeFromExtension(name); | ||
this.inputStream = new FileInputStream(file); | ||
} | ||
|
||
public ClientFile(String name, String mimeType, InputStream inputStream) { | ||
this.name = name; | ||
this.mimeType = mimeType; | ||
this.inputStream = Checker.checkNotNull(inputStream); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getMimeType() { | ||
return mimeType; | ||
} | ||
|
||
public InputStream getInputStream() { | ||
return inputStream; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters