Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:54:55+00:00 2026-06-15T02:54:55+00:00

I am currently downloading Files from Amazon S3 using the .NET SDK, I currently

  • 0

I am currently downloading Files from Amazon S3 using the .NET SDK, I currently have the following code to do it (only these files are allowed):

    With request
        .WithBucketName(bucketName)
        .WithKey(key)
    End With
    response2 = client.GetObject(request)
    Dim strReader As MemoryStream = New MemoryStream
    response2.ResponseStream.CopyTo(strReader)

    Response.ContentType = getContentType(key)
    Response.OutputStream.Write(strReader.GetBuffer, 0, strReader.GetBuffer.Length)
    Dim fileName As String = Path.GetFileName(key)
    Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName)
    Return ""

End Function
Private Function getContentType(ByVal fileToContent As String) As String
    Dim fileExtension As String = Path.GetExtension(fileToContent)
    Dim contentType As String
    Select Case fileExtension
        Case ".bmp"
            contentType = "image/bmp"
        Case ".png"
            contentType = "image/png"
        Case ".xlsx", ".xls"
            contentType = "application/vnd.ms=excel"
        Case ".jpg", ".jpeg", ".gif"
            contentType = "image/jpeg"
        Case ".pdf"
            contentType = "application/pdf"
        Case ".ppt", ".pptx"
            contentType = "application/vnd.ms-powerpoint"
        Case ".doc", ".docx"
            contentType = "application/msword"
        Case Else
            contentType = "text/plain"
    End Select
    Return contentType
End Function

I am having 2 problems: first, when I try to open the files on the client windows tells me (for MS office files) that the files are corrupted, somtimes it manages to open them anyway, sometimes not. Second, it seems that if I the files have extensions like .pptx, and I say ‘PowerPoint’ in the content type, it seems like the browser tries to append an extension to them like ‘.ppt’ or ‘.doc’. Any way to fix that?

EDIT: actual message that I am getting when opening a MS office file: ‘PowerPoint found unreadable content in PowerPointFile.ppt. Do you want to recover the contents of this presentation? If you trust the source of this presentation, click Yes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:54:59+00:00Added an answer on June 15, 2026 at 2:54 am

    OK, for #1, don’t use GetBuffer on MemoryStream. Use ToArray:

    Dim bytes = strReader.ToArray()
    Response.OutputStream.Write(bytes, 0, bytes.Length) 
    

    GetBuffer returns the buffer, not what was written to the stream.

    For #2, you need to use a different MIME type for .***x Office documents. See here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently downloading an HTML page, using the following code: Try Dim req As
I have the following code where I'm trying to download 3 different files from
In an iPhone app I currently have code for downloading a file from the
I am using AxWindowsMediaPlayer on VB.NET to preview MP3 files from the web so
I'm currenlty using Azure Blob to store files, and upload/download from ASP.Net Application hosted
Currently I am using HTML files for parts of my user interface. I display
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);
I need help with downloading from webserver... What i currently do is get XML
Currently I am downloading and parsing my data from an XML file that is
I have the following code in my application in res/xml/preferences.xml: <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android> <PreferenceCategory android:title=Wi-Fi

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.