Tweetsharp Twitter API - post multiple images - asp.net

The code below works and will post to Twitter, but will only ever post one image to the account, even if three images are sent.
These are only jpg or png files, not video or animated gifs.
Any ideas would be appreciated.
Dim service = New TwitterService(key, secret)
service.AuthenticateWith(token, tokenSecret)
Dim opt As New SendTweetWithMediaOptions
Dim images As New Dictionary(Of String, IO.Stream)
Dim myStream As FileStream
If Len(ImgName1) > 0 Then
myStream = New FileStream(ImgName1, FileMode.Open)
images.Add("1", myStream)
End If
If Len(ImgName2) > 0 Then
myStream = New FileStream(ImgName2, FileMode.Open)
images.Add("2", myStream)
End If
If Len(ImgName3) > 0 Then
myStream = New FileStream(ImgName3, FileMode.Open)
images.Add("3", myStream)
End If
opt.Status = TweetText
opt.Images = images
Dim TwitterStatus = service.SendTweetWithMedia(opt)

The code I used to get it working using TweetInvi https://github.com/linvi/tweetinvi (installed via Nuget) is:
(Imports Tweetinvi)
Auth.SetUserCredentials(key, secret, token, tokenSecret)
Dim params As New Tweetinvi.Parameters.PublishTweetOptionalParameters()
params.Medias = New List(Of Models.IMedia)
Dim MediaIDs As String = String.Empty
Dim ids As New List(Of Long)
If Len(ImgName1) > 0 Then
Dim imgFile1 As Byte() = System.IO.File.ReadAllBytes(ImgName1)
Dim myMedia1 = Upload.UploadImage(imgFile1)
ids.Add(myMedia1.MediaId)
imgFile1 = Nothing
End If
If Len(ImgName2) > 0 Then
Dim imgFile2 As Byte() = System.IO.File.ReadAllBytes(ImgName2)
Dim myMedia2 = Upload.UploadImage(imgFile2)
ids.Add(myMedia2.MediaId)
imgFile2 = Nothing
End If
If Len(ImgName3) > 0 Then
Dim imgFile3 As Byte() = System.IO.File.ReadAllBytes(ImgName3)
Dim myMedia3 = Upload.UploadImage(imgFile3)
ids.Add(myMedia3.MediaId)
imgFile3 = Nothing
End If
params.MediaIds = ids
Dim myTweet = Tweet.PublishTweet("blah, blah, blah", params)

The API end point called by that TweetSharp method doesn't support multiple images (I don't think it ever did, but either way the current docs say no; https://dev.twitter.com/rest/reference/post/statuses/update_with_media).
What you need to do is use the UploadMedia endpoint to upload the image and capture the id for each, then send a tweet with the list of ids.
I'm not sure which variant of TweetSharp you're using. The official/original one has known bugs in the Nuget package, and while the source in the repo has those fixed it is lacking the newer API support.
You could try TweetMoaSharp (mostly maintained by me), as I believe this supports the new end points (but it's been a while since I looked). There's also tweetsharp-alternative on Nuget and a few others floating around that might have support.

Related

Extracting Non-Digital "Signature" Images from PDF with iTextSharp

I've been tasked with a project that needs to read the content of a PDF document with populated form fields and save the content to a database. Once the data extracted I should be able to re-create the document using a master copy of the template and re-populated form field data.
Our user base will complete the form/template on a mobile device (specifically Android devices for our environment). They will also be using the Adobe Acrobat Reader mobile app to complete the documents. Once completed, each engineer working on the document will sign the document using the signature function in the mobile app (multiple signatures could be present on multiple pages) and submit the form (which currently emails a copy of the completed PDF to a specific email address).
Once I have a copy of the completed PDF document I am able to read the AcroForm fields using from a .NET application using the iTextSharp library and do whatever I need to do with it (store field "name" and "value" in a database)
Dim reader As PdfReader = New PdfReader(pdfBytes)
Dim pdfFormFields As AcroFields = reader.AcroFields
For Each formField In reader.AcroFields.Fields.Keys
Dim ff As New FormField
ff.Name = formField
ff.Value = pdfFormFields.GetField(formField)
Do_stuff_with(ff)
Next
I'm then able to re-populate the blank pdf template at a later stage with the form data, however am struggling to read the "signature" aspect of it embedded in the file.
When completed via the Acrobat Reader Android app I believe the "signature" isn't technically a signature in the proper "Digital Signature" sense that it can be read using the iTextSharp AcroFields.GetSignatureNames() or AcroFields.GetSignatureDictionary methods. Instead I beleive the signature is stored as a Stream object within an Annotation in the document however I'm currently unable to read and convert this into a Byte Array to store in a database.
I know I will also need to get the page/position of each signature so that I can re-populate at a later stage.
I've tried several methods including extracting all Images from the document but this only extracts embedded images that existed in the template and not the annotation signatures. With a blank dummy document containing just a submit button and signature I get an error after getting the dictionary object PdfName.RESOURCES as if nothing exists.
Dim pdf as New PdfReader(bytes)
For i As Int16 = 1 To pdf.NumberOfPages
Dim pg As PdfDictionary = pdf.GetPageN(i)
Dim res As PdfDictionary = CType(PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES)), PdfDictionary)
' ###
' ###
' ### Errors on next line with
' ### "Object reference not set to an instance of an object"
' ###
' ###
Dim xobj As PdfDictionary = CType(PdfReader.GetPdfObject(pg.Get(PdfName.XOBJECT)), PdfDictionary)
If xobj IsNot Nothing Then
For Each name As PdfName In xobj.Keys
Dim obj As PdfObject = xobj.Get(name)
If obj.IsIndirect Then
Dim tg As PdfDictionary = CType(PdfReader.GetPdfObject(obj), PdfDictionary)
Dim type As PdfName = CType(PdfReader.GetPdfObject(tg.Get(PdfName.SUBTYPE)), PdfName)
If PdfName.IMAGE.Equals(type) Then
Dim xrefIdx As Integer = CType(obj, PRIndirectReference).Number
Dim pdfObj As PdfObject = pdf.GetPdfObject(xrefIdx)
Dim str As PdfStream = CType(pdfObj, PdfStream)
Dim bytes As Byte() = PdfReader.GetStreamBytesRaw(CType(str, PRStream))
Dim img As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(CType(obj, PRIndirectReference))
Dim filter As String = tg.Get(PdfName.FILTER).ToString
If filter = "/DCTDecode" Then
Dim img2 As System.Drawing.Image = System.Drawing.Image.FromStream(New MemoryStream(bytes))
Dim stream As MemoryStream = New MemoryStream
img2.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
stream.Position = 0
PdfReader.KillIndirect(obj)
img = iTextSharp.text.Image.GetInstance(stream)
writer.AddDirectImageSimple(img, CType(obj, PRIndirectReference))
End If
End If
End If
Next
End If
Next
If I inspect the document with iText RUPS I can see two Stream objects (Inspect1.png) which I assume are the two signatures in my test document TestDoc_Complete.pdf but I'm unable to extract these either into a Byte Array or Memory Stream so that I can manipulate and save.
Any help (VB/C#) would be appreciated to help me solve this.
Thanks
--EDIT--
I'm now able to loop through the PdfObjects using XrefSize and identify which objects are Streams. I can read the Stream` Bytes and Raw Bytes and output these to a file but these are unreadable by any image viewer.
Dim pdf = New PdfReader(bytes)
Dim obj As PdfObject
For i As Integer = 1 To pdf.XrefSize
Try
obj = pdf.GetPdfObject(i)
If obj IsNot Nothing And obj.IsStream Then
Dim stream As PRStream = CType(obj, PRStream)
Dim type As PdfName = Nothing
Try
type = CType(pdfreader.GetPdfObject(stream.Get(PdfName.FILTER)), PdfName)
Catch ex As Exception
End Try
If type IsNot Nothing And PdfName.FLATEDECODE.Equals(type) Then
Dim b1 As Byte() = pdfreader.GetStreamBytes(stream)
Dim b2 As Byte() = pdfreader.GetStreamBytesRaw(stream)
csLog.AddLog("Stream Length: " & stream.Length, csLogging.DebugLevel.Debug)
csLog.AddLog("bytes1 Length: " & b1.Length, csLogging.DebugLevel.Debug)
csLog.AddLog("bytes2 Length: " & b2.Length, csLogging.DebugLevel.Debug)
Dim fos As FileStream
' ### Write Bytes to file for testing
fos = New FileStream(Server.MapPath(".") & "\bytes1" & i, FileMode.Create)
fos.Write(b1, 0, b1.Length)
fos.Flush()
fos.Close()
' ### Write RawBytes to file for testing
fos = New FileStream(Server.MapPath(".") & "\bytes2" & i, FileMode.Create)
fos.Write(b2, 0, b2.Length)
fos.Flush()
fos.Close()
' ### CONVERSION ATTEMPTS
ConvertAttempt1(b2, i) ' ### Using Raw Bytes
ConvertAttempt2(stream, i)
End If
End If
Catch ex As Exception
End Try
Next
The first file using b1 appears to be a text representation of the PRStream
q
.160714 0 0 .160714 0 0 cm
0.00000 0.00000 0.00000 RG 0.00000 0.00000 0.00000 rg 1 J 1 j 26.48880 w 488.00000 115.43372 m 488.00000 115.43372 l S 20.37600 w 184.00000 155.43372 m 184.00000 155.43372 184.00000 155.43372 182.44000 156.45367 c S 20.37600 w
.....
.....
.....
which I assume are the vector graphic curves/strokes.
The output of b2 (raw bytes) has the same content length of the signatures I am expecting (3305 and 4834) as shown in the two sterams in iText RUPS.
I've attempted to convert the bytes to an image (JPG) but get errors
' ### Conversion attempt 1
Sub ConvertAttempt1(ByVal rawBytes As Byte(), ByVal xRef As Int16)
Try
Using memStream As MemoryStream = New MemoryStream(rawBytes)
memStream.Position = 0
' ###
' ###
' ### Falls over on next line - "Parameter is not valid"
' ###
' ###
Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(memStream)
Dim path As String = System.IO.Path.Combine(Server.MapPath("."), String.Format("convert1_{0}.jpg", xRef))
Dim parms As System.Drawing.Imaging.EncoderParameters = New System.Drawing.Imaging.EncoderParameters(1)
parms.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 0)
Dim jpegEncoder As System.Drawing.Imaging.ImageCodecInfo = GetImageEncoder("JPEG")
img.Save(path, jpegEncoder, parms)
End Using
Catch ex As Exception
'csLog.AddLog(ex.Message, csLogging.DebugLevel.Errors)
'csLog.AddLog(ex.StackTrace, csLogging.DebugLevel.Errors)
End Try
End Sub
and
Sub ConvertAttempt2(ByVal stream As PRStream, ByVal xRef As Int16)
' ### Conversion attempt 2
Try
' ###
' ###
' ### Falls over on next line - "Object reference not set to an instance of an object."
' ###
' ###
Dim pdfImage As PdfImageObject = New PdfImageObject(stream)
Dim img As System.Drawing.Image = pdfImage.GetDrawingImage()
Dim path As String = System.IO.Path.Combine(Server.MapPath("."), String.Format("convert2_{0}.jpg", xRef))
Dim parms As System.Drawing.Imaging.EncoderParameters = New System.Drawing.Imaging.EncoderParameters(1)
parms.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 0)
Dim jpegEncoder As System.Drawing.Imaging.ImageCodecInfo = GetImageEncoder("JPEG")
img.Save(path, jpegEncoder, parms)
Catch ex As Exception
csLog.AddLog(ex.Message, csLogging.DebugLevel.Errors)
csLog.AddLog(ex.StackTrace, csLogging.DebugLevel.Errors)
End Try
End Sub

Print SSRS Report from Code (asp.net)

I have found good information on how to automatically download a file to the client advertised as a solution of how to print using code
(https://forums.asp.net/t/1233841.aspx?How+do+I+print+from+Reporting+Services+AUTOMATICALLY+in+VB+Net+web+app+)
but what I need to do is have the code print the document without the user interacting.
From what I have found it appears this can not be done as one might casually think. ReportViewer for example does not have a 'print' method.
The only two solutions appears to be to use ProcessStart (which then means saving the file to the file system before printing which I dont want to do)
or maybe (will be researching this today) create a subscription using code and then delete it later.
You are not able to print a report directly from your asp.net page. The reason for this is security. If it allowed you to send a file through the network and onto the clients computer, and then search the computer for a printer, this could cause major security issues. The report viewer does have a print icon, but this disappears when you deploy the project and run the page remotely. I have faced the same issue in the past and found it best to just export the report to say PDF and allow the user to Download it. I have used the below code to accomplish this task in the past:
Private Sub CreatePDFMatrix(fileName As String)
' ReportViewer1.LocalReport.DataSources.Clear()
Dim adapter As New ReportDataSetTableAdapters.vwPrintTagsTableAdapter
Dim table As New ReportDataSet.vwPrintTagsDataTable
Dim month = MonthName(Date.Today.Month)
Dim year = Date.Today.Year
Dim p(1) As ReportParameter
Dim warnings() As Warning
Dim streamIds As String()
Dim mimeType As String = String.Empty
Dim encoding As String = String.Empty
Dim extension As String = String.Empty
Dim adpt2 As New ReportDataSetTableAdapters.vwPrintTagsTableAdapter
adapter.FillForMainReport(table, DropDownList1.SelectedValue, g_Company, g_Division)
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", CType(table, DataTable))) 'Add(New ReportDataSource("ReportingData", CType(table, DataTable)))
Me.ReportViewer1.DataBind()
Dim viewer = ReportViewer1
viewer.ProcessingMode = ProcessingMode.Local
viewer.LocalReport.ReportPath = "Report1.rdlc"
p(0) = New ReportParameter("MonthYear", month & "-" & year)
Dim check = DropDownList1.SelectedValue
ReportViewer1.LocalReport.SetParameters(p(0))
p(1) = New ReportParameter("Location", DropDownList1.SelectedValue)
ReportViewer1.LocalReport.SetParameters(p(1))
Try
Dim bytes As Byte() = viewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, ".pdf", streamIds, warnings)
Response.Buffer = True
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", Convert.ToString((Convert.ToString("attachment; filename=") & fileName) + ".") & extension)
Response.BinaryWrite(bytes)
' create the file
Response.Flush()
Catch ex As Exception
Debug.Print(ex.ToString)
End Try
End Sub

Downloading html as string

I am trying to download a webpage as string. Can someone please explain why the following code doesn't work?
Dim URL As String = "http://stackoverflow.com/"
Dim client As WebClient = New WebClient()
Dim data As Stream = client.OpenRead(URL)
Dim reader As StreamReader = New StreamReader(data)
Dim str As String = ""
str = reader.ReadLine()
Do While str.Length > 0
Console.WriteLine(str)
str = reader.ReadLine()
Loop
When I run it it never goes inside the loop.
Give this a shot...
Dim URL As String = "http://stackoverflow.com/"
Dim html As String = New WebClient().DownloadString(URL)
Better Solution (Releases resources that the network stack is using. Also ensure's (hope) the CLR cleans these up when needed.)
Using client As New WebClient()
html = client.DownloadString(URL)
End Using

How to get Description of Youtube embeded videos in my asp.net application?

I am using the below code to get the Title and description of the youtube video embeded in my asp.net application. I am able to see the Title, but not description.
I use Atomfeed to do this...
Problem is i get the Description as "Google.GData.Client.AtomTextConstruct" for all my videos.
Private Function GetTitle(ByVal myFeed As AtomFeed) As String
Dim strTitle As String = ""
For Each entry As AtomEntry In myFeed.Entries
strTitle = entry.Title.Text
Next
Return strTitle
End Function
Private Function GetDesc(ByVal myFeed As AtomFeed) As String
Dim strDesc As String = ""
For Each entry As AtomEntry In myFeed.Entries
strDesc = entry.Summary.ToString()
Next
Return strDesc
End Function
I believe that when the XML from the atom feed is parsed, that the description is not handled. Take a look at this: http://code.google.com/p/google-gdata/wiki/UnderstandingTheUnknown
But what happens with things that are not understood? They end up as
an element of the ExtensionElements collection, that is a member of
all classes inherited from AtomBase, like AtomFeed, AtomEntry,
EventEntry etc...
So, what we can do is pull out the description from the extensionelement like this:
Dim query As New FeedQuery()
Dim service As New Service()
query.Uri = New Uri("https://gdata.youtube.com/feeds/api/standardfeeds/top_rated")
Dim myFeed As AtomFeed = service.Query(query)
For Each entry In myFeed.Entries
For Each obj As Object In entry.ExtensionElements
If TypeOf obj Is XmlExtension Then
Dim xel As XElement = XElement.Parse(TryCast(obj, XmlExtension).Node.OuterXml)
If xel.Name = "{http://search.yahoo.com/mrss/}group" Then
Dim descNode = xel.Descendants("{http://search.yahoo.com/mrss/}description").FirstOrDefault()
If descNode IsNot Nothing Then
Console.WriteLine(descNode.Value)
End If
Exit For
End If
End If
Next
Next
Also, the reason why you are getting "Google.GData.Client.AtomTextConstruct" is because Summary is an object of type Google.GData.Client.AtomTextConstruct, so doing entry.Summary.ToString() is just giving you the default ToString() behavior. You would normally do Summary.Text, but this of course is blank because as I say above, it's not handled properly by the library.
For youtube, I fetch the information for each video using the Google.GData.YouTube.
Something like this returns a lot of information from the video.
Dim yv As Google.YouTube.Video
url = New Uri("http://gdata.youtube.com/feeds/api/videos/" & video.Custom)
r = New YouTubeRequest(New YouTubeRequestSettings("??", "??"))
yv = r.Retrieve(Of Video)(url)
Then it's possible to get the description with: yv.Description

Converting image into stream

I'm using a function that uploads an image, takes the stream and resizes it using imageresizer.net, then uploads the stream to Amazon S3.
Now I want to take a local picture and convert it into a stream. (to resize and upload to amazonS3). Basically, how do you convert an image into a stream.
This might be a simple question, just could not find the answer anywhere.
Here is some basic code.
Public Shared Sub MoveToAmazon(strImg As String, SKU As String)
Dim fullImg As String = "C:\ImageLocation\" & strImg
Dim img As Image = Image.FromFile(fullImg)
'Here Im missing the code to convert it to a stream.
UploadImage(imgStream, SKU)
End Sub
Public Shared Sub UploadImage(imgStream As Stream, imgName As String)
Dim MainStream As Stream = New MemoryStream
Dim HomeStream As Stream = New MemoryStream
Dim SmallStream As Stream = New MemoryStream
Dim TinyStream As Stream = New MemoryStream
Dim MidStream As Stream = New MemoryStream
Dim GridStream As Stream = New MemoryStream
Dim ListStream As Stream = New MemoryStream
Dim c As New ImageResizer.Configuration.Config
Dim SourceImage As Bitmap = New Bitmap(imgStream)
Dim SourceMain As Bitmap = New Bitmap(SourceImage)
Dim SourceHome As Bitmap = New Bitmap(SourceImage)
Dim SourceSmall As Bitmap = New Bitmap(SourceImage)
Dim SourceTiny As Bitmap = New Bitmap(SourceImage)
Dim SourceMid As Bitmap = New Bitmap(SourceImage)
Dim SourceGrid As Bitmap = New Bitmap(SourceImage)
Dim SourceList As Bitmap = New Bitmap(SourceImage)
ImageResizer.ImageBuilder.Current.Build(SourceMain, MainStream, New ResizeSettings("width=300&height=372&scale=both&paddingWidth=40")) 'ProductPage
ImageResizer.ImageBuilder.Current.Build(SourceHome, HomeStream, New ResizeSettings("width=112&height=147&scale=both")) 'HomePage Products
ImageResizer.ImageBuilder.Current.Build(SourceGrid, GridStream, New ResizeSettings("width=149&height=149&scale=both")) 'Categories Grid
ImageResizer.ImageBuilder.Current.Build(SourceList, ListStream, New ResizeSettings("width=171&height=206&scale=both")) 'Categories List
ImageResizer.ImageBuilder.Current.Build(SourceSmall, SmallStream, New ResizeSettings("width=64&height=75&scale=both")) 'Accessories
ImageResizer.ImageBuilder.Current.Build(SourceTiny, TinyStream, New ResizeSettings("width=82&height=82&scale=both")) 'Cart
ImageResizer.ImageBuilder.Current.Build(SourceMid, MidStream, New ResizeSettings("width=155&height=116&scale=both")) 'CategoryMain
AmazonUploadFile("OriginalImages/" & imgName, imgStream)
AmazonUploadFile("MainImages/" & imgName, MainStream)
AmazonUploadFile("HomeImages/" & imgName, HomeStream)
AmazonUploadFile("GridImages/" & imgName, GridStream)
AmazonUploadFile("ListImages/" & imgName, ListStream)
AmazonUploadFile("SmallImages/" & imgName, SmallStream)
AmazonUploadFile("TinyImages/" & imgName, TinyStream)
AmazonUploadFile("MidImages/" & imgName, MidStream)
End Sub
Public Shared Sub AmazonUploadFile(S3Key As String, FileStream As Stream)
Dim request As New PutObjectRequest()
request.WithBucketName(BUCKET_NAME)
request.WithKey(S3Key).InputStream = FileStream
request.WithCannedACL(S3CannedACL.PublicRead)
GetS3Client.PutObject(request)
End Sub
[Disclaimer - I'm the author of the ImageResizing.NET library the OP is asking the question about.]
Folks - do NOT use Bitmap and Image instances if you can possibly avoid it. There is a giant list of pitfalls that will crash your server. Do NOT use ANYTHING from System.Drawing without a server-safe wrapper around it.
#dash - Your code is almost right, aside from the memory leaks.
Decoding and encoding images safely isn't straightforward. Let the ImageResizing.Net library handle it.
Dim settings as New ResizeSettings("width=64&height=75&scale=both")
Using ms As New MemoryStream()
ImageBuilder.Current.Build("C:\ImageLocation\" & strImg, ms, settings)
ms.Seek(0, SeekOrigin.Begin)
UploadImage(ms, SKU)
End Using
Never load something into a Bitmap or Image instance if you're making multiple versions. Clone the file into a MemoryStream instead.
Using fs as New FileStream(...)
Using ms as MemoryStream = Util.StreamUtils.CopyStream(fs)
'For loop here with your setting variations
ms.Seek(0, SeekOrigin.Begin)
'Place upload and resize code here
'End Loop
End Using
End Using
The following code snippet should do what you want:
Using myImage = Image.FromFile(fullImg)
Using ms As New MemoryStream()
myImage.Save(ms, ImageFormat.Jpeg)
ms.Seek(0, SeekOrigin.Begin)
UploadImage(ms, SKU)
End Using
End Using
As an aside, you might find it easier to parameterize your methods and do all the work when calling them. Something like the following may make your life easier (this assumes the code you posted is code you are actually using and not a demo):
Public Shared Sub UploadImages()
'Call this for each image
MoveToAmazon("C:\ImageLocation\blah.jpg", "OriginalImage", 300, 300, 0, "whatever")
End Sub
Public Shared Sub MoveToAmazon(strImg As String, targetFolder As String, height as Integer, width as Integer, padding as Integer, SKU As String)
Dim fullImg As String = "" & strImg
Using img = Image.FromFile(fullImg)
'Here Im missing the code to convert it to a stream.
Using ms As New MemoryStream()
Image.Save(ms, ImageFormat.Jpeg)
ms.Seek(0, SeekOrigin.Begin)
UploadImage(ms, SKU)
End Using
End Using
End Sub
Public Shared Sub UploadImage(imgStream As Stream, imgName As String, targetFolder As String, height as Integer, width as Integer, padding as Integer, SKU As String)
Dim c As New ImageResizer.Configuration.Config
ImageResizer.ImageBuilder.Current.Build(SourceMain, imgStream, New ResizeSettings("width=" & CStr(width) & "&height=" & CStr(height) & "&scale=both&paddingWidth=" & CStr(padding))
AmazonUploadFile(targetFolder & "/" & imgName, imgStream)
End Sub
Public Shared Sub AmazonUploadFile(S3Key As String, FileStream As Stream)
Dim request As New PutObjectRequest()
request.WithBucketName(BUCKET_NAME)
request.WithKey(S3Key).InputStream = FileStream
request.WithCannedACL(S3CannedACL.PublicRead)
GetS3Client.PutObject(request)
End Sub
Using ms As New MemoryStream()
Image.Save(ms, ImageFormat.Jpeg)
ms.Seek(0, SeekOrigin.Begin)
UploadImage(ms, SKU)
End Using
Read the image bytes and then you wrap it in a MemoryStream
MemoryStream ms = new MemoryStream(imageBytes);

Resources