I Need Help on how to download attachments on M8 Release

(sussegaduss) #1

Hi All…

I have a Corda application running on M6 Release. This app includes inclusion and download of attachments.

To open an attachment, i used to use this approach, inside my API (Accessible from the UI through REST)

val attachment = serviceHub.storageService.attachments.openAttachment(id)
return Response.ok(attachment!!).build()

When i upgraded my code to M8, however, the attachments api changed, and i dont have an easy way to do the same. The only methods i have, that are accessible by IdentityAPI (the REST API) are:


How can i do to download an attachment on M8, since i cannot use the same code from M6 anymore?


(Clinton Alexander) #2

Hello @sussegaduss

From your API you should only have an RPC interface of type CordaRpcOps (see here for an example).

But you are correct, that functionality did not get ported from the old server to the new server implementation. I’ll see if this is intentional or something we should patch.


(Clinton Alexander) #3

We have a task in the backlog to sort this out. In the meantime I am not sure there is a workaround. If you’re comfortable doing so you could add this interface into the core RPC interface and PR it to the Corda repo.

(Clinton Alexander) #4

Hello again @sussegaduss

There is a pending pull request to add this functionality to our RPC interface here.

Once this has been merged to master would you be comfortable using snapshot 0.9 to have access to this feature?


(Clinton Alexander) #5

One final post for today; the fix is now in master.

(sussegaduss) #6

Hi Clinton,

I will try to upgrade the code to 0.9 and come back to you.

Thanks for the help!

(sussegaduss) #7

Hi Clinton.

Any chance that you port this feature to M8? Im getting issues when trying to upgrade to 0.9-SNAPSHOT.


(Clinton Alexander) #8

Hi @sussegaduss

I’ll have time today to cut an M8.2 release with this fix. I’ll reply here when it’s out.


(Clinton Alexander) #9

Hi @sussegaduss

You can now checkout the release-M8.2 branch after fetching latest with git. It has a new interface openAttachment on the RPC API.

(Srinidhi) #10

@Clinton_Alexander There isnt any implementation on things to attach. Is there any Java reference where i can use attachments in my application ?

(Clinton Alexander) #11

@srinidhi The implementation can be found in CordaRPCOpsImpl.kt. The JavaDoc can be found on our docsite.

(Mike Hearn) #12

There is also a dedicated sample under the samples directory called attachment-demo

(Clinton Alexander) #13

Which incidentally doesn’t test downloading of attachments, which it now probably should.