Closed C0deWithAj closed 5 years ago
Hi @Ajmalajji, please forgive us for such a late answer. I am a new maintainer of this project.
There are two separate issues here:
Filestack-java is not directly connected with Android broadcast system
Unfortunately, Client
class from filestack-java artifact is not directly connected with UploadStatusReceiver
. You can receive broadcasts only if you upload your files through the Filestack Picker activity.
Async methods usage All of our async method calls are now relying on RxJava2 (we will get rid of that soon and we will replace those with regular callbacks). If you would like to receive results, you need to subscribe to a Flowable returned by us. Here is a minimum code sample, based on your example:
Client client = new Client(config);
client.uploadAsync(imageFile.getAbsolutePath(), true)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Progress<FileLink>>() {
@Override
public void accept(Progress<FileLink> fileLinkProgress) {
if (fileLinkProgress.getData() != null) {
//your file has been uploaded
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
// en error occured
}
});
I will close this issue. Please, fell free to reopen it if you have any additional questions.
How to define AndroidSchedulers in the example shared above @scana ?
How to define AndroidSchedulers in the example shared above @scana ?
@khurana3192 You are required to add https://github.com/ReactiveX/RxAndroid dependency to your project.
@scana Thanks for the prompt response. But this method of uploading the file silently fails. Neither I get any error/crashes and it never uploads as well.
Here is my code
private void uploadFileStack(String pathmila) {
Config config = new Config("MY_FILESTACK_API_KEY");
Client client = new Client(config);
client.uploadAsync(pathmila, true)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Progress<FileLink>>() {
@Override
public void accept(Progress<FileLink> fileLinkProgress) {
if (fileLinkProgress.getData() != null) {
//your file has been uploaded
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
// en error occured
}
});
}
That's unexpected. Are you sure that you do not receive anything here?
new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
Log.e("MyLogs", throwable.getMessage(), throwable)
}
@scana Thanks again for that quick reply. I really appreciate this.
Here's what I get after logging throwable. throwable.getMessage() is empty, but here's what throwable shows
E/MyLogs: com.filestack.HttpException: at com.filestack.internal.Util.throwHttpResponseException(Util.java:71) at com.filestack.internal.RetryNetworkFunc.responseOkay(RetryNetworkFunc.java:118) at com.filestack.internal.RetryNetworkFunc.run(RetryNetworkFunc.java:55) at com.filestack.internal.RetryNetworkFunc.call(RetryNetworkFunc.java:34) at com.filestack.internal.UploadStartFunc.call(UploadStartFunc.java:33) at com.filestack.internal.UploadStartFunc.call(UploadStartFunc.java:12) at io.reactivex.internal.operators.flowable.FlowableFromCallable.subscribeActual(FlowableFromCallable.java:37) at io.reactivex.Flowable.subscribe(Flowable.java:14409) at io.reactivex.Flowable.subscribe(Flowable.java:14356) at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764)
Ok, so this seems like a failure with this particular request. What can you do is:
HttpException exception = (HttpException) throwable;
// log this to find out which HTTP code is it:
exception.code()
If this is not enough, you may set up a breakpoint at this point: https://github.com/filestack/filestack-java/blob/master/src/main/java/com/filestack/internal/Util.java#L46 and figure out with a debugger what is the actual response body (that might explain why do you get this error).
Unfortunately, I am no longer maintaining this project, so I can't help any further.
@scana .
code() has a private access in com.filestack.HttpException! That's the error I get when I try to access exception.code();
I need some assistance here to get this thing running for my Android app.
I am happily using your services on our web portal and paying $99 a month (+ overages) and expecting a solution here.
Who should be the best person to contact in this case?
Hi,
I am trying to upload image using Client class manually. I have used EasyImage library that loads images fine . I registered the UploadStatusReceiver in onCreateView of fragment like this:
this is how i am using Client class to upload image asynchronously
But the Broadcast receiver never gets called. I have checked the image path given as string, its okay.
Following is device details:
Device: Nexus 5 OS : Android 7.0
Please let me know what am i missing or doing wrong ?