Examples of GcsFileOptions


Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

    return createGcsFileMetadata(entity, filename);
  }

  private GcsFileMetadata createGcsFileMetadata(Entity entity, GcsFilename filename)
      throws IOException {
    GcsFileOptions options;
    try (ObjectInputStream in = new ObjectInputStream(
        new ByteArrayInputStream(((Blob) entity.getProperty(OPTIONS_PROP)).getBytes()))) {
      options = (GcsFileOptions) in.readObject();
    } catch (ClassNotFoundException e1) {
      throw new RuntimeException(e1);
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

            break;
          default:
        }
      }
    }
    GcsFileOptions options = optionsBuilder.build();
    return new GcsFileMetadata(filename, options, etag, length, lastModified);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, world from java");
    GcsService gcsService = GcsServiceFactory.createGcsService();
    GcsFilename filename = new GcsFilename(BUCKETNAME, FILENAME);
    GcsFileOptions options = new GcsFileOptions.Builder()
        .mimeType("text/html")
        .acl("public-read")
        .addUserMetadata("myfield1", "my field value")
        .build();
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

    Long id_max = (Long)em.createQuery("select max(rr.id) from RosieRecords rr where rr.used =0").getSingleResult(); // this will give you the current record's id
    Long id_min = (Long)em.createQuery("select min(rr.id) from RosieRecords rr where rr.used =0").getSingleResult(); // this will give you the current record's id
    em.close();
    RosieRecordsService rrs = new RosieRecordsService();
    GcsFilename filename = new GcsFilename(BUCKETNAME, "RosieConversion_" + (new Date()).toString());
    GcsFileOptions options = new GcsFileOptions.Builder().mimeType("text/html").acl("public-read").build();
        //.addUserMetadata("myfield1", "my field value").build();
    GcsOutputChannel writeChannel;
    try {
      writeChannel = gcsService.createOrReplace(filename, options);
      // You can write to the channel using the standard Java methods.
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

    }
  }

  @Override
  public void beginShard() throws IOException {
    GcsFileOptions fileOptions = new GcsFileOptions.Builder().mimeType(mimeType).build();
    channel = GCS_SERVICE.createOrReplace(file, fileOptions);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

    @Test
    @InSequence(1)
    public void testCreateGsObj() throws IOException {
        GcsFilename filename = new GcsFilename(bucket, OBJECT_NAME);
        GcsFileOptions option = new GcsFileOptions.Builder()
            .mimeType("text/html")
            .acl("public-read")
            .build();

        try (GcsOutputChannel writeChannel = gcsService.createOrReplace(filename, option)) {
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

    @Test
    @InSequence(4)
    public void testOptionsAndMetadata() throws IOException {
        GcsFilename filename = new GcsFilename(bucket, OBJECT_NAME + "4");
        GcsFileOptions option = new GcsFileOptions.Builder()
            .acl("public-read")
            .cacheControl("Cache-Control: public, max-age=3600")
            .contentEncoding("Content-Encoding: gzip")
            .contentDisposition("Content-Disposition: attachment")
            .mimeType("text/html")
            .addUserMetadata("userKey", "UserMetadata")
            .build();

        GcsOutputChannel writeChannel = gcsService.createOrReplace(filename, option);
        try (PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"))) {
            out.println(CONTENT);
            out.flush();
        }

        GcsFileMetadata metaData = gcsService.getMetadata(filename);
        GcsFileOptions option2 = metaData.getOptions();
        try {
            assertEquals(filename, metaData.getFilename());
        } finally {
            gcsService.delete(filename);
        }

        assertEquals("Cache-Control: public, max-age=3600", option2.getCacheControl());
        assertEquals("Content-Encoding: gzip", option2.getContentEncoding());
        assertEquals("Content-Disposition: attachment", option2.getContentDisposition());
        assertEquals("text/html", option2.getMimeType());
        assertEquals("Content-Encoding: gzip", option2.getContentEncoding());
        Map<String, String> userMetadata = option2.getUserMetadata();
        assertEquals(1, userMetadata.size());
        String key = userMetadata.keySet().iterator().next();
        assertEquals("UserMetadata", userMetadata.get(key));
        assertEquals("public-read", option2.getAcl());
    }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFileOptions

        final long ts = System.currentTimeMillis();
        final byte[] bytes = "FooBar".getBytes();

        GcsService service = GcsServiceFactory.createGcsService();
        GcsFilename filename = new GcsFilename("GcsBucket", String.valueOf(ts));
        GcsFileOptions options = new GcsFileOptions.Builder().mimeType(CONTENT_TYPE).build();
        try (GcsOutputChannel out = service.createOrReplace(filename, options)) {
            IOUtils.copy(Channels.newChannel(new ByteArrayInputStream(bytes)), out);
        }

        BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.