Uploading a file from my application (Indy / Delphi) to an ASP page and then to another server (Amazon S3)

I need to store files on Amazon AWS S3, but in order to isolate the user from AWS authentication, I want to go through the ASP page on my site where the user will be logged in. So:

The application sends the file using the Delphi Indy library of the TidHTTP.Put library (FileStream) to the ASP page along with some authentication materials (mine, not AWS) in querystring.

The ASP page checks the authorization data, and then, if OK saves the file to S3, using my Amazon account.

I have a question: how do I access data coming from Indy PUT using JScript on an ASP page and pass it to S3. I am fine with the signature of AWS, etc., It's just nuts and bolts connecting two bits (incoming request and outgoing AWS request) ...

TIA R

+3
source share
2 answers

A HTTP PUT will store the file in the specified location in the HTTP header - it "requests the enclosed object is stored under the supplied Request-URI".

The disadvantage of the PUT method is that if you are in a collaborative hosting environment, it may not be available to you.

, - PUT, () . PUT , ASP:

PUT - : CGI ASP . PUT - , ISAPI

http://www.15seconds.com/issue/981120.htm

, PUT POST, URL-, ASP script ?

+2

, Ive . ASP:

    var PostedDataSize   = Request.TotalBytes ;
    var PostedData       = Request.BinaryRead (PostedDataSize) ;

    var PostedDataStream = Server.CreateObject ("ADODB.Stream") ; 
    PostedDataStream.Open ;
    PostedDataStream.Type = 1 ;                    // binary
    PostedDataStream.Write (PostedData) ;

    Response.Write ("PostedDataStream.Size = " + PostedDataStream.Size + "<br>") ;

    var XML = AmazonAWSPUTRequest (BucketName, AWSDestinationFileID, PostedDataStream) ;
    .....

    function AmazonAWSPUTRequest (Bucket, Filename, InputStream) 

    {
    ....
    XMLHttp.open ("PUT", URL + FRequest, false) ;

    XMLHttp.setRequestHeader (....
    XMLHttp.setRequestHeader (....
    ...
    Response.Write ("InputStream.Size = " + InputStream.Size + "<br>") ;
    XMLHttp.send (InputStream)  ;     

BinaryRead, . , , , , - . ( ), / AWS PUT.

AWS , , ! InputStream.Size , , - .

?

POSTSCRIPT. . . , reset , . :

    XMLHttp.send (InputStream)  ; 

:

   InputStream.Position = 0 ;

.

0

Source: https://habr.com/ru/post/1737886/


All Articles