public static KnownSizeInputStream of(String contents) { return of(contents.getBytes()); }
public static InputStream newInputStreamWithContents(String contents) { byte[] bytes = checkNotNull(contents, "contents").getBytes(Charsets.UTF_8); return KnownSizeInputStream.of(bytes); }
public SshPutTaskFactory contents(byte[] contents) { markDirty(); this.contents = Suppliers.ofInstance(KnownSizeInputStream.of(contents)); return self(); }
public SshPutTaskFactory contents(String contents) { markDirty(); this.contents = Suppliers.ofInstance(KnownSizeInputStream.of(contents)); return self(); }
/** returns the creation script contents, if it exists, or null if none is defined (error if it cannot be loaded) */ @Nullable public static InputStream getDatabaseCreationScript(Entity entity) { String url = entity.getConfig(DatastoreMixins.CREATION_SCRIPT_URL); if (!Strings.isBlank(url)) return new ResourceUtils(entity).getResourceFromUrl(url); String templateUrl = entity.getConfig(DatastoreMixins.CREATION_SCRIPT_TEMPLATE); if (!Strings.isBlank(templateUrl)) { String template = TemplateProcessor.processTemplateContents(new ResourceUtils(entity).getResourceAsString(templateUrl), (EntityInternal) entity, ImmutableMap.<String, Object>of()); try { return new ByteArrayInputStream(template.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw Exceptions.propagate(e); } } String contents = entity.getConfig(DatastoreMixins.CREATION_SCRIPT_CONTENTS); if (!Strings.isBlank(contents)) return KnownSizeInputStream.of(contents); return null; }