Category Archives: amazon

File upload issue while calling Amazon Drive API

I am consuming Amazon drive api in Java Http Client. I am successfull while calling most of the apis. But there is one api "upload File" that I am getting issue in. Below is the code snippet that I am using for uploding the file:

HttpClient client = new  DefaultHttpClient();

    try {

        File file = new File("E:\\sampleworkspace\\Amazon\\src\\Sample.jpg");


        if (!file.exists()) {
            System.err.println("File does not exist");
            return;
        }else {
            System.out.println("== "+file);
        }
        System.out.println("URL to post " + URL);
        HttpPost post = new HttpPost(URL);
        post.addHeader("Authorization", "Bearer " + token);
        FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
        StringBody stringBody1 = new StringBody("Sample", ContentType.MULTIPART_FORM_DATA);
        StringBody stringBody2 = new StringBody("FILE", ContentType.MULTIPART_FORM_DATA);
        //
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
        builder.addPart("upfile", fileBody);
        builder.addPart("name", stringBody1);
        builder.addPart("kind", stringBody2);

        HttpEntity entity = builder.build();

        post.setEntity(entity);




        HttpResponse response = client.execute(post);


        System.out.println("Status "+response.getStatusLine());


    } catch (Exception e) {

    }

Amazon Api that I am hitting from the code: https://content-jp.drive.amazonaws.com/cdproxy/

While hitting this api, I am getting "400 Bad Rquest" everytime. Can someone please help me out.

Regards, Munish

My homepage wont go through HTTPS port

So my domain is www.urtina.com and as u can see whenever you go on that link it will get HTTP (without padlock) but if you go to any other link it will be HTTPS. Only my homepage goes through HTTP.

Important things to mention is that I use Apache. Every my attempt to edit .htaccess file ends up by website stoping to work. My whole website is hosted on AWS and that is where I derived my SSL certificate.

I want to make that homepage load in HTTPS as well. How should I do that . Here is my app folder and place where I created my .htaccess file I would appreciate your help.

How can i install LAMP packages properly?

I have a virtual machine on the amazon cloud (AWSE2).Red hat 7 runs on it.I would like to install lamp stack on it.I have a connection via putty.when i tried to execute sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd

i get something like that and i am stuck in it. Loaded plugins: amazon-id, rhui-lb, search-disabled-repos

  • No package httpd24 available. No package php56 available. No package mysql55-server available. No package php56-mysqlnd available.

Amazon Instance WebServer Windows

I got a Amazon AWS Free Instance, but i can't connect to the Webserver running on it, using the Public IP.

I'm using Apache2, checked 127.0.0.1 to see if service is running and it is.

I found alot of articles saying about Security Groups on Amazon PANEL,

So i made Group for Port 80, Anywhere(0.0.0.0) TCP , Still can't connect,

Tried a bunch of Groups, Even opening 0-65k and still can't connect thru Public IP.

Does anybody knows why i can't connect , i'm not an Amazon AWS expert, never used it, and starting to not like it, since any other Dedicated server that i got as easy like cake to make things running.

Thanks in advance,

Amazon S3 get file without extension

I'm uploading multiple pictures with different extensions (jpg, png...etc) via java Amazon TransferManager.

for example : picture1.png, picture2.jpg. I would like to serve the content without the extension, a get request to folder/picture1 would return picture1.png.

The client is an angularJs application

Previously, I was hosting all these picture on EC2 and serving it via APACHE with option Multiviews, is there something similar we can do with AmazonS3 ?

Thanks

Apache Virtual host only resolving on Chrome

I'm having a strange issue with a linux machine under Amazon cloud. I configured virtual host on it to use a subdomain but it only works when I access from Chrome. I tried to run it on other machines and with Safari and Firefox and it behaves the same way.

Below is the content of the .conf file:

<VirtualHost *:80>

        ServerName subdomain.company.com
        DocumentRoot /var/www/html/subdomain/public
        <Directory "/var/www/html/subdomain/public">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

How can I make my Apache virtual host rules to be resolver properly?

Certificate Mismatch Errors

I've seen variations of this question asked but none have the solution to this exact case.

I have a WP site that is dumping assets on to CloudFront via W3 Total Cache plugin. Accessing the domain via http://domain.com works fine, however using www.domain.com generates a stop message from Amazon.

ERROR The request could not be satisfied. Bad request. Generated by cloudfront (CloudFront)

I checked the SSL using SSL Checker. http://domain.com shows the correct chain however www shows a certificate mismatch and a broken chain.

Thoughts were I could edit the htaccess file to force requests to www to http or https, however nothing I have tired seems to perform the redirect.

I don't see any rewrites below that would prevent forcing www requests to non www.

Any suggestions on how to force this redirect or for that matter if this is the correct solution?

  # BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
<FilesMatch "\.(css|htc|less|js|js2|js3|js4|CSS|HTC|LESS|JS|JS2|JS3|JS4)$">
    FileETag MTime Size
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public"
         Header set X-Powered-By "W3 Total Cache/0.9.4.1"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    FileETag MTime Size
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=3600, public"
         Header set X-Powered-By "W3 Total Cache/0.9.4.1"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|WOFF|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    FileETag MTime Size
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "max-age=31536000, public"
         Header set X-Powered-By "W3 Total Cache/0.9.4.1"
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC CDN
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# END W3TC CDN
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN W3TC Skip 404 error handling by WordPress for static files
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(robots\.txt|[a-z0-9_\-]*sitemap[a-z0-9_\-]*\.(xml|xsl|html)(\.gz)?)
    RewriteCond %{REQUEST_FILENAME} \.(css|htc|less|js|js2|js3|js4|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip)$ [NC]
    RewriteRule .* - [L]
</IfModule>
# END W3TC Skip 404 error handling by WordPress for static files
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Issue with amazon CDN, error 502 on JS and font files

I am about to setup a cdn for my website using amazon cloud front.

It works nicely with pictures, but will throw errors on font and js files. The rules are set up exactly the same, I don't know why I am getting this error:

Font from origin 'foo' has been blocked from loading by Cross-Origin 
Resource Sharing policy. No 'Access-Control-Allow-Origin' header is 
present on the requested resource. Origin 'bar' is therefore not 
allowed access. The response had HTTP status code 502.

I read about the Access-Control-Allow-Origin header and added it to .htaccess like this but to no avail:

Header add Access-Control-Allow-Origin "*"

(Also tried with Domain name, no difference.

Any hint is highly appreciated.

Separating static web pages from WAR file

I have a web application which is a WAR file. I will be hosting this in Amazon cloud, using Linux and Tomcat. However I now need to create a different UI using HTML and CSS, no Java or WAR. My plan is, user will access this static user interface first and from a link there, they will access the actual java based web application.

There are 2 ways I can do this. First is to put all of this static content into the WAR file. Second is seprating the static content from the WAR file. I prefer the second method, because I can add info to the user interfaces without shutting down the entire web application.

But, how can I do this? How can I put these static files to tomcat and link the WAR file to it? Specially is this is possible in amazon cloud?

The requested URL xxx was not found on this server

I am using wordpress and when I switch the permalinks to "post name", it doesn't load the page rather showing 404 not found. The requested URL xxx was not found on this server. It's on Amazon AWS EC2

I already tried changing .htaccess and I confirmed rewrite_mode is enabled. Even I changed the AllowOverride to All.

Here is the .htaccess content,

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress

Any idea, what could be the issue?