Skip to content

Commit

Permalink
Rename FileUpload to UploadFile to match other ServiceStack libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Nov 25, 2024
1 parent 1434bc9 commit 163fe93
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 88 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ for updates, or [StackOverflow](http://stackoverflow.com/questions/ask) or the [

This repository contains the source for ServiceStack plugins for the leading Android Studio, IntelliJ and Eclipse Java IDE's providing Java developers a highly productive development experience for consuming Typed ServiceStack Services by leveraging [Add ServiceStack Reference](https://github.com/ServiceStack/ServiceStack/wiki/Add-ServiceStack-Reference) directly within their IDE!

### v1.1.5 Changes

- Rename FileUpload to `UploadFile` to match other ServiceStack libraries

### v1.1.4 Changes

Added new ServiceClient APIs:
Expand Down
2 changes: 1 addition & 1 deletion src/AndroidClient/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

// Define the version and group for the Maven package
version = "1.1.4"
version = "1.1.5"
group = "net.servicestack"

if (project.hasProperty('versionSuffix')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.servicestack.client.JsonServiceClient;
import net.servicestack.client.Utils;
import net.servicestack.cookies.SerializableCookieStore;
import net.servicestack.client.FileUpload;
import net.servicestack.client.UploadFile;

import java.lang.reflect.Type;
import java.net.CookieHandler;
Expand Down Expand Up @@ -911,29 +911,29 @@ public void deleteAsync(String path, AsyncSuccess<byte[]> success) {
}

@Override
public <T> void postFileWithRequestAsync(IReturn<T> request, FileUpload file, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(this.apiUrl(request), request, new FileUpload[]{file}, request.getResponseType(), asyncResult);
public <T> void postFileWithRequestAsync(IReturn<T> request, UploadFile file, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(this.apiUrl(request), request, new UploadFile[]{file}, request.getResponseType(), asyncResult);
}
@Override
public <T> void postFileWithRequestAsync(Object request, FileUpload file, Object responseType, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(this.apiUrl(request), request, new FileUpload[]{file}, responseType, asyncResult);
public <T> void postFileWithRequestAsync(Object request, UploadFile file, Object responseType, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(this.apiUrl(request), request, new UploadFile[]{file}, responseType, asyncResult);
}
@Override
public <T> void postFileWithRequestAsync(String path, Object request, FileUpload file, Object responseType, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(path, request, new FileUpload[]{file}, responseType, asyncResult);
public <T> void postFileWithRequestAsync(String path, Object request, UploadFile file, Object responseType, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(path, request, new UploadFile[]{file}, responseType, asyncResult);
}

@Override
public <T> void postFilesWithRequestAsync(IReturn<T> request, FileUpload[] files, final AsyncResult<T> asyncResult) {
public <T> void postFilesWithRequestAsync(IReturn<T> request, UploadFile[] files, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(this.apiUrl(request), request, files, request.getResponseType(), asyncResult);
}
@Override
public <T> void postFilesWithRequestAsync(Object request, FileUpload[] files, Object responseType, final AsyncResult<T> asyncResult) {
public <T> void postFilesWithRequestAsync(Object request, UploadFile[] files, Object responseType, final AsyncResult<T> asyncResult) {
this.<T>postFilesWithRequestAsync(this.apiUrl(request), request, files, responseType, asyncResult);
}

@Override
public <T> void postFilesWithRequestAsync(String path, Object request, FileUpload[] files, Object responseType, final AsyncResult<T> asyncResult) {
public <T> void postFilesWithRequestAsync(String path, Object request, UploadFile[] files, Object responseType, final AsyncResult<T> asyncResult) {
final AndroidServiceClient client = this;
execTask(new AsyncTask<String, Void, T>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package net.servicestack.client;

import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.util.Map;

public interface AsyncServiceClient {
Expand Down Expand Up @@ -79,11 +78,11 @@ public interface AsyncServiceClient {
void deleteAsync(String path, final AsyncResult<byte[]> asyncResult);
void deleteAsync(String path, final AsyncSuccess<byte[]> success);

<T> void postFileWithRequestAsync(IReturn<T> request, FileUpload file, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(Object request, FileUpload file, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(String path, Object request, FileUpload file, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(IReturn<T> request, UploadFile file, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(Object request, UploadFile file, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(String path, Object request, UploadFile file, Object responseType, final AsyncResult<T> asyncResult);

<T> void postFilesWithRequestAsync(IReturn<T> request, FileUpload[] files, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(Object request, FileUpload[] files, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(String path, Object request, FileUpload[] files, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(IReturn<T> request, UploadFile[] files, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(Object request, UploadFile[] files, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(String path, Object request, UploadFile[] files, Object responseType, final AsyncResult<T> asyncResult);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -685,31 +684,31 @@ public void clearCookies() {

// Convenience method for single file upload
@Override
public <TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, FileUpload file) {
return postFilesWithRequest(this.apiUrl(request), request, new FileUpload[]{file}, request.getResponseType());
public <TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, UploadFile file) {
return postFilesWithRequest(this.apiUrl(request), request, new UploadFile[]{file}, request.getResponseType());
}
@Override
public <TResponse> TResponse postFileWithRequest(Object request, FileUpload file, Object responseType) {
return postFilesWithRequest(this.apiUrl(request), request, new FileUpload[]{file}, responseType);
public <TResponse> TResponse postFileWithRequest(Object request, UploadFile file, Object responseType) {
return postFilesWithRequest(this.apiUrl(request), request, new UploadFile[]{file}, responseType);
}
@Override
public <TResponse> TResponse postFileWithRequest(String path, Object request, FileUpload file, Object responseType) {
return postFilesWithRequest(path, request, new FileUpload[]{file}, responseType);
public <TResponse> TResponse postFileWithRequest(String path, Object request, UploadFile file, Object responseType) {
return postFilesWithRequest(path, request, new UploadFile[]{file}, responseType);
}

@Override
public <TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, FileUpload[] files) {
public <TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, UploadFile[] files) {
return this.postFilesWithRequest(this.apiUrl(request), request, files, request.getResponseType());
}
@Override
public <TResponse> TResponse postFilesWithRequest(Object request, FileUpload[] files, Object responseType) {
public <TResponse> TResponse postFilesWithRequest(Object request, UploadFile[] files, Object responseType) {
return this.postFilesWithRequest(this.apiUrl(request), request, files, responseType);
}

private static final String BOUNDARY = "---" + UUID.randomUUID().toString() + "---";

@Override
public <TResponse> TResponse postFilesWithRequest(String path, Object request, FileUpload[] files, Object responseType) {
public <TResponse> TResponse postFilesWithRequest(String path, Object request, UploadFile[] files, Object responseType) {
try {
// Prepare multipart data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand All @@ -724,7 +723,7 @@ public <TResponse> TResponse postFilesWithRequest(String path, Object request, F
}

// Add files
for (FileUpload file : files) {
for (UploadFile file : files) {
writeMultipartFile(dos, file);
}

Expand All @@ -751,13 +750,13 @@ private void writeMultipartField(DataOutputStream dos, String fieldName, String
dos.writeBytes(value + "\r\n");
}

private void writeMultipartFile(DataOutputStream dos, FileUpload file) throws IOException {
private void writeMultipartFile(DataOutputStream dos, UploadFile file) throws IOException {
dos.writeBytes("--" + BOUNDARY + "\r\n");
dos.writeBytes("Content-Disposition: form-data; name=\"" + file.getFieldName() +
"\"; filename=\"" + file.getFileName() + "\"\r\n");
dos.writeBytes("Content-Type: " + file.getContentType() + "\r\n");
dos.writeBytes("\r\n");
dos.write(file.getFileBytes());
dos.write(file.getContents());
dos.writeBytes("\r\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public interface ServiceClient {
String getTokenCookie();
String getRefreshTokenCookie();

<TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, FileUpload file);
<TResponse> TResponse postFileWithRequest(Object request, FileUpload file, Object responseType);
<TResponse> TResponse postFileWithRequest(String path, Object request, FileUpload file, Object responseType);
<TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, UploadFile file);
<TResponse> TResponse postFileWithRequest(Object request, UploadFile file, Object responseType);
<TResponse> TResponse postFileWithRequest(String path, Object request, UploadFile file, Object responseType);

<TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, FileUpload[] files);
<TResponse> TResponse postFilesWithRequest(Object request, FileUpload[] files, Object responseType);
<TResponse> TResponse postFilesWithRequest(String path, Object request, FileUpload[] files, Object responseType);
<TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, UploadFile[] files);
<TResponse> TResponse postFilesWithRequest(Object request, UploadFile[] files, Object responseType);
<TResponse> TResponse postFilesWithRequest(String path, Object request, UploadFile[] files, Object responseType);
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package net.servicestack.client;

public class FileUpload {
public class UploadFile {
private String fieldName;
private String fileName;
private String contentType;
private byte[] fileBytes;
private byte[] contents;

public FileUpload(String fieldName, String fileName, String contentType, byte[] fileBytes) {
public UploadFile(String fieldName, String fileName, String contentType, byte[] contents) {
this.fieldName = fieldName;
this.fileName = fileName;
this.contentType = contentType != null ? contentType : "application/octet-stream";
this.fileBytes = fileBytes;
this.contents = contents;
}

public String getFieldName() { return fieldName != null ? fieldName : "upload"; }
public String getFileName() { return fileName; }
public String getContentType() { return contentType; }
public byte[] getFileBytes() { return fileBytes; }
public byte[] getContents() { return contents; }
}
2 changes: 1 addition & 1 deletion src/AndroidClient/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

// Define the version and group for the Maven package
version = "1.1.4"
version = "1.1.5"
group = "net.servicestack"

if (project.hasProperty('versionSuffix')) {
Expand Down
2 changes: 1 addition & 1 deletion src/AndroidClient/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.servicestack</groupId>
<artifactId>client</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
<name>ServiceStack.Client</name>
<description>A client library to call your ServiceStack webservices.</description>
<url>https://github.com/ServiceStack/ServiceStack.Java</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package net.servicestack.client;

import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.util.Map;

public interface AsyncServiceClient {
Expand Down Expand Up @@ -79,11 +78,11 @@ public interface AsyncServiceClient {
void deleteAsync(String path, final AsyncResult<byte[]> asyncResult);
void deleteAsync(String path, final AsyncSuccess<byte[]> success);

<T> void postFileWithRequestAsync(IReturn<T> request, FileUpload file, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(Object request, FileUpload file, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(String path, Object request, FileUpload file, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(IReturn<T> request, UploadFile file, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(Object request, UploadFile file, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFileWithRequestAsync(String path, Object request, UploadFile file, Object responseType, final AsyncResult<T> asyncResult);

<T> void postFilesWithRequestAsync(IReturn<T> request, FileUpload[] files, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(Object request, FileUpload[] files, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(String path, Object request, FileUpload[] files, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(IReturn<T> request, UploadFile[] files, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(Object request, UploadFile[] files, Object responseType, final AsyncResult<T> asyncResult);
<T> void postFilesWithRequestAsync(String path, Object request, UploadFile[] files, Object responseType, final AsyncResult<T> asyncResult);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -685,31 +684,31 @@ public void clearCookies() {

// Convenience method for single file upload
@Override
public <TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, FileUpload file) {
return postFilesWithRequest(this.apiUrl(request), request, new FileUpload[]{file}, request.getResponseType());
public <TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, UploadFile file) {
return postFilesWithRequest(this.apiUrl(request), request, new UploadFile[]{file}, request.getResponseType());
}
@Override
public <TResponse> TResponse postFileWithRequest(Object request, FileUpload file, Object responseType) {
return postFilesWithRequest(this.apiUrl(request), request, new FileUpload[]{file}, responseType);
public <TResponse> TResponse postFileWithRequest(Object request, UploadFile file, Object responseType) {
return postFilesWithRequest(this.apiUrl(request), request, new UploadFile[]{file}, responseType);
}
@Override
public <TResponse> TResponse postFileWithRequest(String path, Object request, FileUpload file, Object responseType) {
return postFilesWithRequest(path, request, new FileUpload[]{file}, responseType);
public <TResponse> TResponse postFileWithRequest(String path, Object request, UploadFile file, Object responseType) {
return postFilesWithRequest(path, request, new UploadFile[]{file}, responseType);
}

@Override
public <TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, FileUpload[] files) {
public <TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, UploadFile[] files) {
return this.postFilesWithRequest(this.apiUrl(request), request, files, request.getResponseType());
}
@Override
public <TResponse> TResponse postFilesWithRequest(Object request, FileUpload[] files, Object responseType) {
public <TResponse> TResponse postFilesWithRequest(Object request, UploadFile[] files, Object responseType) {
return this.postFilesWithRequest(this.apiUrl(request), request, files, responseType);
}

private static final String BOUNDARY = "---" + UUID.randomUUID().toString() + "---";

@Override
public <TResponse> TResponse postFilesWithRequest(String path, Object request, FileUpload[] files, Object responseType) {
public <TResponse> TResponse postFilesWithRequest(String path, Object request, UploadFile[] files, Object responseType) {
try {
// Prepare multipart data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand All @@ -724,7 +723,7 @@ public <TResponse> TResponse postFilesWithRequest(String path, Object request, F
}

// Add files
for (FileUpload file : files) {
for (UploadFile file : files) {
writeMultipartFile(dos, file);
}

Expand All @@ -751,13 +750,13 @@ private void writeMultipartField(DataOutputStream dos, String fieldName, String
dos.writeBytes(value + "\r\n");
}

private void writeMultipartFile(DataOutputStream dos, FileUpload file) throws IOException {
private void writeMultipartFile(DataOutputStream dos, UploadFile file) throws IOException {
dos.writeBytes("--" + BOUNDARY + "\r\n");
dos.writeBytes("Content-Disposition: form-data; name=\"" + file.getFieldName() +
"\"; filename=\"" + file.getFileName() + "\"\r\n");
dos.writeBytes("Content-Type: " + file.getContentType() + "\r\n");
dos.writeBytes("\r\n");
dos.write(file.getFileBytes());
dos.write(file.getContents());
dos.writeBytes("\r\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public interface ServiceClient {
String getTokenCookie();
String getRefreshTokenCookie();

<TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, FileUpload file);
<TResponse> TResponse postFileWithRequest(Object request, FileUpload file, Object responseType);
<TResponse> TResponse postFileWithRequest(String path, Object request, FileUpload file, Object responseType);
<TResponse> TResponse postFileWithRequest(IReturn<TResponse> request, UploadFile file);
<TResponse> TResponse postFileWithRequest(Object request, UploadFile file, Object responseType);
<TResponse> TResponse postFileWithRequest(String path, Object request, UploadFile file, Object responseType);

<TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, FileUpload[] files);
<TResponse> TResponse postFilesWithRequest(Object request, FileUpload[] files, Object responseType);
<TResponse> TResponse postFilesWithRequest(String path, Object request, FileUpload[] files, Object responseType);
<TResponse> TResponse postFilesWithRequest(IReturn<TResponse> request, UploadFile[] files);
<TResponse> TResponse postFilesWithRequest(Object request, UploadFile[] files, Object responseType);
<TResponse> TResponse postFilesWithRequest(String path, Object request, UploadFile[] files, Object responseType);
}
Loading

0 comments on commit 163fe93

Please sign in to comment.