Streaming with IAttachmentFile

Discussions related to custom development with Select.
Post Reply
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Streaming with IAttachmentFile

Post by toddsou »

Hi-

In order to efficiently handle the creation (and extraction) of large attachments with SPS, we're interested in the IAttachmentFile's CopyTo( ) method, which accepts a Stream.

1) I'm assuming I can build a class which derives from Stream and is capable of providing the next set of bytes from my Source whenever the SDK calls Read on the given Stream within the CopyTo's implementation. Is that a safe assumption?

2) As the bytes are streamed to the IAttachmentFile via the CopyTo( ) method, are they accumulating in the client's memory footprint, or is the SDK sending them on to the server for appending to the corresponding Blob storage ? Put another way, if we use this operation, and then the user closes the open Order without saving, what happens to the new attachment ? Kept or discarded?

Thank you.
-Todd
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Streaming with IAttachmentFile

Post by BobRichards »

In order to write content to an IAttachmentFile, you can use either:
  • Use SetStream(Stream stream, string extension) and pass in an object that implements the Stream functionality. (As you correctly stated.)
  • Or use SetStream(string path) and pass the filesystem location of a file.
Adding attachment files will cause the order to become dirty and if the user closes Select then a dialog will pop up to ask the user to save the order before exiting. If the order is not saved by the user, the changes (new attachment files) will be lost.

By the way, CopyTo() would be used if you wanted to read a copy of the attachment file and write it to another destination - not if you wanted to provide content to be written to an attachment file. (I find the method names confusing too.)
Bob Richards, Senior Software Developer, SoftPro
Post Reply