Skip to content

Commit

Permalink
Merge 0afb419 into 6567405
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnmaten committed Sep 3, 2017
2 parents 6567405 + 0afb419 commit a222179
Show file tree
Hide file tree
Showing 23 changed files with 931 additions and 367 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -11,5 +11,8 @@ cache:
jdk:
- oraclejdk8

script:
- TEST_TYPE='unit' ./gradlew check

after_success:
- ./gradlew jacocoTestReport coveralls
111 changes: 61 additions & 50 deletions build.gradle
Expand Up @@ -11,16 +11,20 @@ apply plugin: 'maven-publish'

group = 'com.filestack'
sourceCompatibility = 1.7
version = getVersion()
version = file(new File('VERSION')).text.trim() // Get version string from VERSION text file

repositories {
jcenter()
// ***************************************** Config ***********************************************

configurations {
integTestCompile.extendsFrom testCompile
integTestRuntime.extendsFrom testRuntime
integTestImplementation.extendsFrom testImplementation
}

dependencies {
testImplementation 'junit:junit:4.12' // Testing
testImplementation 'org.mockito:mockito-core:2.8.47' // Mocking
testImplementation 'com.squareup.retrofit2:retrofit-mock:2.3.0' // Testing helpers for Retrofit
testImplementation 'com.squareup.retrofit2:retrofit-mock:2.3.0' // Helpers for Retrofit

compile 'com.squareup.okhttp3:okhttp:3.8.0' // Low-level HTTP client
compile 'com.squareup.retrofit2:retrofit:2.3.0' // High-level HTTP client
Expand All @@ -34,36 +38,40 @@ dependencies {
compile 'io.reactivex.rxjava2:rxjava:2.1.2' // Observable pattern for async methods
}


// ***************************************** General Config ***************************************

checkstyle {
toolVersion '8.1'
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}

javadoc {
destinationDir new File("./docs")
options.optionFiles(new File('./config/javadoc/javadoc.txt'))
}

// ***************************************** General Config ***************************************

// Publications define artifacts to upload to Bintray
publishing {
publications {
Maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}

// ***************************************** Version Config ***************************************
repositories {
jcenter()
}

// Get version string from VERSION text file
def getVersion() {
return file(new File('VERSION')).text.trim()
sourceSets {
integTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integTest/java')
}
resources.srcDir file('src/integTest/resources')
}
}

// Create version properties file from VERSION text file
// ***************************************** Tasks ************************************************

// Output version to version.properties file
task createProperties(dependsOn: processResources) {
doLast {
new File("$buildDir/resources/main/version.properties").withWriter { w ->
Expand All @@ -74,28 +82,33 @@ task createProperties(dependsOn: processResources) {
}
}

// Add task to build process
classes {
dependsOn createProperties
// Run integration tests
task integTest(type: Test) {
testClassesDir = sourceSets.integTest.output.classesDir
classpath = sourceSets.integTest.runtimeClasspath
outputs.upToDateWhen { false }
}

// ***************************************** Version Config ***************************************

// Create javadoc artifact jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

// ***************************************** Bintray Config ***************************************
// Create source artifact jar
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

// Publications define artifacts to upload to Bintray
publishing {
publications {
Maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
classes.dependsOn createProperties // Create version.properties as part of build
integTest.mustRunAfter test // Run integration tests after unit tests
tasks.withType(Test) { // Put unit and integration test reports in separate directories
reports.html.destination = file("${reporting.baseDir}/${name}")
}

// Bintray publishing config
// *************************************** Plugin Config ******************************************

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser')
: System.getenv('BINTRAY_USER')
Expand Down Expand Up @@ -127,15 +140,13 @@ bintray {
}
}

// Tasks for creating artifact jars
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
checkstyle {
toolVersion '8.1'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}

// ***************************************** Bintray Config ***************************************
24 changes: 24 additions & 0 deletions src/main/java/com/filestack/FileLink.java
Expand Up @@ -6,8 +6,10 @@
import com.filestack.errors.ResourceNotFoundException;
import com.filestack.errors.ValidationException;
import com.filestack.responses.ImageTagResponse;
import com.filestack.transforms.AvTransform;
import com.filestack.transforms.ImageTransform;
import com.filestack.transforms.ImageTransformTask;
import com.filestack.transforms.tasks.AvTransformOptions;
import com.filestack.util.FsService;
import com.filestack.util.Util;
import com.google.gson.Gson;
Expand Down Expand Up @@ -307,6 +309,28 @@ public boolean imageSfw()
return json.get("sfw").getAsBoolean();
}

/**
* Creates an {@link AvTransform} object for this file using default storage options.
*
* @see #avTransform(StorageOptions, AvTransformOptions)
*/
public AvTransform avTransform(AvTransformOptions avOptions) {
return avTransform(null, avOptions);
}

/**
* Creates an {@link AvTransform} object for this file using custom storage options.
* A transformation call isn't made directly by this method.
* For both audio and video transformations.
*
* @param storeOptions options for how to save the file(s) in your storage backend
* @param avOptions options for how ot convert the file
* @return {@link AvTransform ImageTransform} instance configured for this file
*/
public AvTransform avTransform(StorageOptions storeOptions, AvTransformOptions avOptions) {
return new AvTransform(this, storeOptions, avOptions);
}

// Async method wrappers

/**
Expand Down
44 changes: 34 additions & 10 deletions src/main/java/com/filestack/FilestackClient.java
Expand Up @@ -88,7 +88,7 @@ public FilestackClient build() {
/**
* Upload local file using default storage options.
*
* @see #upload(String, UploadOptions)
* @see #upload(String, StorageOptions, boolean)
*/
public FileLink upload(String pathname)
throws ValidationException, IOException, PolicySignatureException,
Expand All @@ -99,23 +99,36 @@ public FileLink upload(String pathname)
/**
* Upload local file using custom storage options.
*
* @param pathname path to the file, can be local or absolute
* @param options storage options, https://www.filestack.com/docs/rest-api/store
* @see #upload(String, StorageOptions, boolean)
*/
public FileLink upload(String pathname, StorageOptions options)
throws ValidationException, IOException, PolicySignatureException,
InvalidParameterException, InternalException {
return upload(pathname, options, true);
}

/**
* Upload local file using custom storage and upload options.
*
* @param pathname path to the file, can be local or absolute
* @param options storage options, https://www.filestack.com/docs/rest-api/store
* @param intelligent intelligent ingestion, improves reliability for bad networks
* @return new {@link FileLink} referencing file
* @throws ValidationException if the pathname doesn't exist or isn't a regular file
* @throws IOException if request fails because of network or other IO issue
* @throws PolicySignatureException if security is missing or invalid
* @throws InvalidParameterException if a request parameter is missing or invalid
* @throws InternalException if unexpected error occurs
*/
public FileLink upload(String pathname, UploadOptions options)
public FileLink upload(String pathname, StorageOptions options, boolean intelligent)
throws ValidationException, IOException, PolicySignatureException,
InvalidParameterException, InternalException {

if (options == null) {
options = new UploadOptions.Builder().build();
options = new StorageOptions.Builder().build();
}

Upload upload = new Upload(pathname, this, options, fsService, delayBase);
Upload upload = new Upload(pathname, options, intelligent, delayBase, this, fsService);
return upload.run();
}

Expand All @@ -124,7 +137,7 @@ public FileLink upload(String pathname, UploadOptions options)
/**
* Asynchronously upload local file using default storage options.
*
* @see #upload(String, UploadOptions)
* @see #upload(String, StorageOptions, boolean)
*/
public Single<FileLink> uploadAsync(String pathname) {
return uploadAsync(pathname, null);
Expand All @@ -133,13 +146,24 @@ public Single<FileLink> uploadAsync(String pathname) {
/**
* Asynchronously upload local file using custom storage options.
*
* @see #upload(String, UploadOptions)
* @see #upload(String, StorageOptions, boolean)
*/
public Single<FileLink> uploadAsync(final String pathname, final UploadOptions options) {
public Single<FileLink> uploadAsync(final String pathname, final StorageOptions options) {
return uploadAsync(pathname, options, true);
}

/**
* Asynchronously upload local file using custom storage and upload options.
*
* @see #upload(String, StorageOptions, boolean)
*/
public Single<FileLink> uploadAsync(final String pathname, final StorageOptions options,
final boolean intelligent) {

return Single.fromCallable(new Callable<FileLink>() {
@Override
public FileLink call() throws Exception {
return upload(pathname, options);
return upload(pathname, options, intelligent);
}
})
.subscribeOn(Schedulers.io())
Expand Down

0 comments on commit a222179

Please sign in to comment.