ImpCode
ImpCode
======================
package com.mkyong.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Controller
public class UploadController {
@GetMapping("/")
public String index() {
return "upload";
}
if (file.isEmpty()) {
redirectAttributes.addFlashAttribute("message", "Please select a file
to upload");
return "redirect:uploadStatus";
}
try {
redirectAttributes.addFlashAttribute("message",
"You successfully uploaded '" + file.getOriginalFilename() +
"'");
} catch (IOException e) {
e.printStackTrace();
}
return "redirect:/uploadStatus";
}
@GetMapping("/uploadStatus")
public String uploadStatus() {
return "uploadStatus";
}
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@RestController
@RequestMapping("/app")
public class ImageResource {
return ResponseEntity.ok()
.headers(header)
.contentLength(file.length())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(resource);
}
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
-buildmode=pie
#!/bin/bash
# A shell script to read file line by line
filename="/Users/vamsi.c/Documents/hostnames.txt"
echo "started"
arr=()
while IFS= read -r line; do
arr+=("$line")
done < $filename
echo $arr
#!/bin/bash
USERNAME="vamsi"
filename="/Users/vamsi.c/Documents/hostnames.txt"
declare -a myArray
myArray=(`cat "$filename"`)
for (( i = 0 ; i < ${#myArray[*]} ; i++))
do
echo "Element [$i]: ${myArray[$i]}"
done
template='{"hostname":"{"%s"}","username":"%s"}'
echo "$json_string"
============================-=============-===============-=============-
=================
#!/bin/bash
USERNAME="vamsi"
USERPASSWORD="@Kavya143"
AppACCOUNTNAME="rdrt"
APPACCOUNTPASSWORD="@Kavya143"
NOTES="Control Test"
filename="/Users/vamsi.c/Documents/demohost"
declare -a myArray
myArray=(`cat "$filename"`)
Qarr=()
j=1
count=$((${#myArray[*]}-$j))
echo "$json_string"
cat <<EOF > /Users/vamsi.c/Documents/jsonbody1.txt
"$json_string"
EOF
# sed -i '$json_string/}/' "/Users/vamsi.c/Documents/jsonbody.txt"