Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleteing files now complies with api v2.1 #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TomRaybould
Copy link

The HttpConnector class is still using the old v2.0 web api for the camera, for deleting images, and does not currently work this way. This commit changes the HttpConnector logic so that it can delete files off the camera using the v2.1 web api. This requires a different callback with an array of multiple image paths which I have created "HttpDeleteFileListener".

https://developers.theta360.com/en/docs/v2.1/api_reference/commands/camera.delete.html

@Kyusung4698
Copy link

any updates on this? i can't delete files with the current sdk version.
W/System.err: java.io.FileNotFoundException: http://127.0.0.1:8080/osc/commands/execute at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:250) at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.getInputStream(TrackedHttpURLConnection.java:374) W/System.err: at com.android.tools.profiler.support.network.httpurl.HttpURLConnection$.getInputStream(HttpURLConnection$.java:207) at com.theta360.pluginapplication.network.HttpConnector.deleteFile(HttpConnector.java:602) at com.theta360.pluginapplication.task.DeleteImageTask.doInBackground(DeleteImageTask.java:21) at com.theta360.pluginapplication.task.DeleteImageTask.doInBackground(DeleteImageTask.java:9) at android.os.AsyncTask$2.call(AsyncTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

@TomRaybould
Copy link
Author

I haven't heard anything from the devs in this project. @kkushimoto and @shohara is there anything I can do to help this pull request along? I didn't see anything in terms of guidelines for pull requests on this project. I tried to keep the added delete functionality in-line with what is already in the code base. Any feedback is appreciated! Thank you!

@codetricity
Copy link
Contributor

@TomRaybould and @Kyusung4698, thanks for the PR. Can you send me and @jcasman an email with information on the plug-in you're building? We want to relay this information on to the team at RICOH when we ask them the status of the PR to help get their attention. Our email is [email protected] and [email protected] We don't work for RICOH, but we talk to people there from time to time.

@Jackdea
Copy link

Jackdea commented Oct 24, 2020

It's not work for me.
I use the example theta-api2.1-android-sdk
and i already fix the parameters name from " fileUri" to "fileUrls" as below:

HttpURLConnection postConnection = createHttpConnection("POST", "/osc/commands/execute");
JSONObject input = new JSONObject();
String responseData;
mHttpEventListener = listener;
InputStream is = null;

try {
    // send HTTP POST
    input.put("name", "camera.delete");
    JSONObject parameters = new JSONObject();
    parameters.put("fileUrls", "image");
    input.put("parameters", parameters);

    OutputStream os = postConnection.getOutputStream(); 
    os.write(input.toString().getBytes());
    postConnection.connect();
    os.flush();
    os.close();

    is = postConnection.getInputStream(); <=====IOException here
    responseData = InputStreamToString(is);

@TomRaybould
Copy link
Author

TomRaybould commented Oct 25, 2020

Hey @Jackdea,

So in all honesty, since making this PR I have since switched jobs and no longer work on anything related to Theta, that being said I think I can still help you here...

First the issue..
v2.0's API
needs only one file URI to delete a given file.

v2.1's API
need a json array of fileId to delete one of more images.

The solution..

It looks like above you are trying to delete a file that is called "image" so in order to get this to work you need to first put that fileId into a JSONArray and then add the array as a param.

 input.put("name", "camera.delete");
JSONObject parameters = new JSONObject();
JSONArray fileIdArray = new JSONArray();
fileIdArray.put("image")
parameters.put("fileUrls", fileIdArray);
input.put("parameters", parameters);

Extra tip:
Also ideal you should change the hardcoded "image" string to a variable so you can pass any file you want to delete to this method. I realize you probably know this and you were just hardcoding for the example, but just my 2 cents.

@Jackdea
Copy link

Jackdea commented Oct 25, 2020

Thanks~~~ It's work!!

        input.put("name", "camera.delete");
        JSONObject parameters = new JSONObject();
        JSONArray fileIdArray = new JSONArray();
        fileIdArray.put(deletedFileId);
        parameters.put("fileUrls", fileIdArray);
        input.put("parameters", parameters);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants