static async uploadFile()

in source/5-unicornPics/webapp/src/Api.tsx [102:125]


    static async uploadFile(file: any) {

        // get the presigned url 
        const signedRequestResp = await this.preparePost();

        // Send the file with due headers for signed request - using RN fetch because URL can be virtually anything
        return await fetch(signedRequestResp.url, {
            method: "PUT",
            body: file,
            headers: {
                'x-amz-meta-userid': signedRequestResp.userid,
                'x-amz-meta-postid': signedRequestResp.postid,
                'x-amz-meta-createdat': signedRequestResp.createdat,
                'x-amz-meta-ownername': signedRequestResp.ownername
            }
        }).then(data => { 
            return 1;
        })
        .catch(err => { 
            console.log(err); 
            return -1; 
        });

    }