UNSOLVED

wisleysit

updated

14 years ago

W

wisleysit

13 Posts

0

5714

January 13th, 2013 19:00

How to rename object?

Dear all,

I try to use the following code to rename my object.

EsuRestApi api = new EsuRestApi(HOST, 443, TOKENID, SECRETKEY);

api.rename(new ObjectPath(old_filename),

                 new ObjectPath(new_filename), false);

However i got some problems when i was testing.

Am I using wrong method to rename object?

01-14 11:31:47.655: E/AndroidRuntime(29647): FATAL EXCEPTION: main

01-14 11:31:47.655: E/AndroidRuntime(29647): com.emc.esu.api.EsuException: There was a mismatch between the signature in the request and the signature computed by the server.

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.emc.esu.api.rest.EsuRestApi.handleError(EsuRestApi.java:2325)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.emc.esu.api.rest.EsuRestApi.rename(EsuRestApi.java:2033)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.cx.ecs.MainActivity$6.onClick(MainActivity.java:429)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.view.View.performClick(View.java:4084)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.view.View$PerformClick.run(View.java:16966)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.os.Handler.handleCallback(Handler.java:615)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.os.Handler.dispatchMessage(Handler.java:92)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.os.Looper.loop(Looper.java:137)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.app.ActivityThread.main(ActivityThread.java:4745)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at java.lang.reflect.Method.invokeNative(Native Method)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at java.lang.reflect.Method.invoke(Method.java:511)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at dalvik.system.NativeStart.main(Native Method)

  • JasonCwik

    1 Rookie

    •

    281 Posts

    1184

    0

    Posted January 14th, 2013 08:00

    What is the destination filename?

    Since the destination file path is sent as an HTTP header, it's important that the EsuRestApi object is in Unicode mode.  This is supported by Atmos 1.4.2+ and 2.0.1+.  You can enable it with:

    api.setUnicodeEnabled(true);

  • chris_arnett

    1 Rookie

    •

    110 Posts

    1184

    0

    Posted January 14th, 2013 09:00

    Make sure your secret key is correct.  You must include the trailing equals sign as well.

  • wisleysit

    13 Posts

    1184

    0

    Posted January 14th, 2013 09:00

    Hi Jason,

    Sorry I am new programer in developing atmos so I don't know what is destination filename.

    I have try to enable unicode however it also not work.

    The following is my code of upload file and rename file.

    try {           

         EsuApi atmosApi = new EsuRestApi( HOST, 443, TOKENID, SECRETKEY );

         UploadHelper uploadHelper = new UploadHelper(atmosApi);

         uploadHelper.createObjectOnPath(new ObjectPath ("/test/text2.txt"), new File(DIR+"/text2.txt"), null, null);

         atmosApi.setUnicodeEnabled(true);

         atmosApi.rename(new ObjectPath("/test/text2.txt"), new ObjectPath("/test/hello.txt"), true);

    } catch(EsuException ex){

         System.out.println(ex.getMessage());

    }

  • JasonCwik

    1 Rookie

    •

    281 Posts

    1184

    0

    Posted January 14th, 2013 09:00

    This all looks fine to me.  What version of the Java API are you using?  What version of Atmos? You can call getServiceInformation to get the version.

    Are you using a service provider (e.g. AT&T)?

  • wisleysit

    13 Posts

    1184

    0

    Posted January 14th, 2013 18:00

    Hi jason,

    My atmos version is 2.0.1.

    Yes, I am using service provider to access atmos.

  • wisleysit

    13 Posts

    1184

    0

    Posted January 14th, 2013 18:00

    Hi chris,

    YA...I use same correct secret key. I also include the trailing equals sign as well.

  • chris_arnett

    1 Rookie

    •

    110 Posts

    1184

    0

    Posted January 14th, 2013 20:00

    Are you still getting the same error message (mismatch between the signature)?  That means either the secret key is bad or something's wrong with the headers.  Since you're using our SDK, I'm inclined to believe it's the prior.  Are you absolutely SURE your secret key is correct?  Is it something you're typing in on the emulator or a string in the code?

    The code you show here does not have any non-latin characters, so unless I'm missing something, I don't think that's the problem.  However, when enabling UTF-8 encoding, be sure to do that right away, (i.e. before calling createObject).

    If you're using the correct token ID and secret key and still getting this message, I would start debugging by hard-coding the tokenID and secret key inside your app first and use ASCII characters in the file names.  If that still doesn't work, perhaps there is a problem in the encryption library when used with Android.  Note that we have not tested the SDK on that platform (it's unfortunate we would even have to since it's Java).

    If it does work, then the problem is in the handling of the credentials.

  • wisleysit

    13 Posts

    1184

    0

    Posted January 14th, 2013 20:00

    Am I need to set permission?

  • wisleysit

    13 Posts

    1184

    0

    Posted January 15th, 2013 03:00

    HI Chris,

    I have try you suggestion but I still getting the same error.

    I have double check my token ID and secret key. It is correct.Also I have try to hard code to my program.

    Am I missing some setting of EsuApi ?

    Is there any other method I can use to change the object name?

    Thanks you.

  • JasonCwik

    1 Rookie

    •

    281 Posts

    288

    0

    Posted January 15th, 2013 07:00

    Are you behind a firewall or proxy?  We've seen some instances where corporate firewalls either modify certain HTTP headers and/or add/remove headers that somehow affects the signature of the request (e.g. change "Content-Type").  Are you running your own internal Atmos or are you using a service provider like AT&T?