List of usage examples for com.amazonaws.services.s3 AmazonS3 getObjectMetadata
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws SdkClientException, AmazonServiceException;
Gets the metadata for the specified Amazon S3 object without actually fetching the object itself.
From source file:cloudExplorer.RestoreObject.java
License:Open Source License
public void run() { String message = null;// ww w .ja v a 2 s . c o m AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); File file = new File(what); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); try { GetObjectMetadataRequest request = new GetObjectMetadataRequest(bucket, what); ObjectMetadata response = s3Client.getObjectMetadata(request); response.getOngoingRestore(); mainFrame.jTextArea1.append("\nRestored operation ran for Object: " + what + ". Please examiene this window for any errors."); mainFrame.calibrateTextArea(); } catch (Exception get) { // mainFrame.jTextArea1.append("\n\nError Message: " + get.getMessage()); } calibrate(); }
From source file:com.dragovorn.dragonbot.DragonBot.java
License:Open Source License
@Override public void start() { setState(BotState.STARTING);//from w w w. jav a 2s .c om AmazonS3 client = AmazonS3ClientBuilder.standard().withRegion(Regions.US_EAST_1).build(); this.transferManager = TransferManagerBuilder.standard().withS3Client(client).build(); UpdatePanel update = new UpdatePanel(); new MainWindow(update); if (Bot.getInstance().getConfiguration().getCheckForUpdates()) { getLogger().info("Checking for newer version of the updater..."); try { if (client .getObjectMetadata( new GetObjectMetadataRequest("dl.dragovorn.com", "DragonBot/updater.jar")) .getLastModified().getTime() > FileManager.getUpdater().lastModified()) { getLogger().info("Found a newer version of the updater, downloading it now..."); FileManager.getUpdater().delete(); GetObjectRequest request = new GetObjectRequest("dl.dragovorn.com", "DragonBot/updater.jar"); try { this.transferManager.download(request, FileManager.getUpdater()).waitForCompletion(); } catch (InterruptedException exception) { /* Shouldn't happen */ } } } catch (Throwable throwable) { getLogger().info("Unable to connect to the internet!"); } getLogger().info("Checking for updates..."); update.update(); if (update.shouldStop()) { stop(); return; } } getLogger().info("Initializing Dragon Bot v" + getVersion() + "!"); this.name = this.config.getName(); this.auth = this.config.getAuth(); this.commandManager.registerCommand(new Github()); this.commandManager.registerCommand(new VersionCmd()); this.pluginManager.enablePlugins(); if (!this.name.equals("") && !this.config.getAuth().equals("")) { getLogger().info("Connecting to twitch!"); try { connect(); } catch (ConnectionException | IOException exception) { getLogger().info("Unable to connect!"); } if (this.config.getAutoConnect() && !this.config.getChannel().equals("")) { getLogger().info("Automatically connected to " + this.config.getChannel()); connectTo("#" + this.config.getChannel()); } } else { String buttons[] = { "Ok" }; JOptionPane.showOptionDialog(null, "You don't have a twitch account configured! Please set the bot's twitch account in the options menu!", "Twitch Account", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, buttons, buttons[0]); getLogger().info("No twitch account detected."); } if (!this.isConnected()) { MainWindow.getInstance().getChannelButton().setEnabled(false); MainWindow.getInstance().getChannelButton() .setToolTipText("The current account was unable to connect!"); } setState(BotState.RUNNING); MainWindow.getInstance().setContentPane(MainWindow.getInstance().getPanel()); MainWindow.getInstance().pack(); MainWindow.getInstance().center(); getLogger().info("Dragon Bot v" + getVersion() + " initialized!"); }
From source file:org.alanwilliamson.amazon.s3.GetInfo.java
License:Open Source License
@Override public cfData execute(cfSession _session, cfArgStructData argStruct) throws cfmRunTimeException { AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonS3 s3Client = getAmazonS3(amazonKey); String bucket = getNamedStringParam(argStruct, "bucket", null); if (bucket == null) throwException(_session, "Please specify a bucket"); String key = getNamedStringParam(argStruct, "key", null); if (key == null) throwException(_session, "Please specify a key"); if (key.charAt(0) == '/') key = key.substring(1);//from w w w. jav a 2 s .co m try { GetObjectMetadataRequest g = new GetObjectMetadataRequest(bucket, key); ObjectMetadata metadata = s3Client.getObjectMetadata(g); cfStructData s = new cfStructData(); s.setData("bucket", new cfStringData(bucket)); s.setData("key", new cfStringData(key)); s.setData("host", new cfStringData(amazonKey.getAmazonRegion().toAWSRegion().getDomain())); Map m = metadata.getRawMetadata(); Iterator<String> it = m.keySet().iterator(); while (it.hasNext()) { String k = it.next(); s.setData(k, tagUtils.convertToCfData(m.get(k))); } return s; } catch (Exception e) { throwException(_session, "AmazonS3: " + e.getMessage()); return cfBooleanData.FALSE; } }