Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Descargar un archivo S3

Estoy construyendo una aplicación web usando AWS S3.

Pregunta: ¿Cómo puedo descargar un archivo de S3 y guardarlo en la carpeta Descargas de los usuarios?

Mi código hasta ahora:

 this.getS3().getObject({Bucket:bucket_name, Key:keys}, function(error, data) { if (error) { console.log("Error!") } else { // How to save 'data' file in Download folder? } });
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Así es como lo estoy haciendo en .NET usando AWS SDK para .Net

 public class AmazonS3 { //Local varaibles to get the accesskey and secretkey private readonly string accessKey; private readonly string secretKey; private RegionEndpoint regionEndpoint; AmazonS3Client client = null; TransferUtility utility = null; /// <summary> /// Class Constructor for getting the accesskey and secretkey for the Amazon S3 bucket /// </summary> public AmazonS3Operations() { //get the accesskey and secretkey from the web.config accessKey = ConfigurationManager.AppSettings["AWSS3AccessKey"]; secretKey = ConfigurationManager.AppSettings["AWSS3SecretKey"]; regionEndpoint = RegionEndpoint.GetBySystemName(ConfigurationManager.AppSettings["AWSS3RegionEndPoint"]); //Initialize the connection here and use it every where in a singleton model client = GetS3ClientConnection(); } public byte[] GetFileObject(string filePath, string fileNameInS3, out string strContentType) { byte[] data = null; GetObjectRequest request = new GetObjectRequest(); request.BucketName = filePath; request.Key = fileNameInS3; //get the object response here GetObjectResponse response = client.GetObject(request); using (MemoryStream ms = new MemoryStream()) { response.ResponseStream.CopyTo(ms); data = ms.ToArray(); } //get the Mimetype here strContentType = MimeMapping.GetMimeMapping(fileNameInS3); return data; } }

Pase sus parámetros al método GetFileObject que devuelve la matriz byte[] en respuesta. Cree el archivo respectivo con el nombre respectivo y el tipo MIME en la carpeta de descarga de los usuarios.

Consulte aquí para hacer lo mismo con Java: http://docs.aws.amazon.com/AmazonS3/latest/dev/RetrievingObjectUsingJava.html

También hay otros documentos de AWS disponibles en línea para otros idiomas.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!