Package freenet.support.io

Examples of freenet.support.io.FileBucket


    Bucket bucket;
    OutputStream os = null;
   
    try {
      try {
        bucket = new FileBucket(certFile, false, false, false, false);
        os = bucket.getOutputStream();
        writeCerts(os);
        // If this fails, we need the whole fetch to fail.
        os.close(); os = null;
      } finally {
View Full Code Here


  public static void main(String arg[]) throws Throwable {
    final File fin = new File("/tmp/test.png");
    final File fout = new File("/tmp/test2.png");
    fout.delete();
    final Bucket inputBucket = new FileBucket(fin, true, false, false, false);
    final Bucket outputBucket = new FileBucket(fout, false, true, false, false);
    InputStream inputStream = null;
    OutputStream outputStream = null;
    try {
      inputStream = inputBucket.getInputStream();
      outputStream = outputBucket.getOutputStream();
      Logger.setupStdoutLogging(LogLevel.MINOR, "");

      ContentFilter.filter(inputStream, outputStream, "image/png",
          new URI("http://127.0.0.1:8888/"), null, null, null);
    } finally {
      Closer.close(inputStream);
      Closer.close(outputStream);
      inputBucket.free();
      outputBucket.free();
    }
  }
View Full Code Here

    }

    private Bucket makePluginStoreBucket(String storeIdentifier, boolean isEncrypted, boolean backup)
    throws FileNotFoundException {
        File f = getPluginStoreFile(storeIdentifier, isEncrypted, backup);
        Bucket bucket = new FileBucket(f, false, true, false, false);
        if(isEncrypted) {
            byte[] key = node.getPluginStoreKey(storeIdentifier);
            if(key != null) {
                // We pad then encrypt, which is wasteful, but we have no way to persist the size.
                // Unfortunately AEADCryptBucket needs to know the real termination point.
View Full Code Here

   
    private Bucket findPluginStoreBucket(String storeIdentifier, boolean isEncrypted, boolean backup)
    throws FileNotFoundException {
        File f = getPluginStoreFile(storeIdentifier, isEncrypted, backup);
        if(!f.exists()) return null;
        Bucket bucket = new FileBucket(f, false, false, false, false);
        if(isEncrypted) {
            byte[] key = node.getPluginStoreKey(storeIdentifier);
            if(key != null) {
                // We pad then encrypt, which is wasteful, but we have no way to persist the size.
                // Unfortunately AEADCryptBucket needs to know the real termination point.
                bucket = new AEADCryptBucket(bucket, key);
                bucket = new PaddedBucket(bucket, bucket.size());
            }
        }
        return bucket;
    }
View Full Code Here

              // Guess MIME type
                outsb.append(" using MIME type: ").append(mimeType).append("\r\n");
              if(mimeType.equals(DefaultMIMETypes.DEFAULT_MIME_TYPE))
                mimeType = ""; // don't need to override it
             
              FileBucket fb = new FileBucket(f, true, false, false, false);
              InsertBlock block = new InsertBlock(fb, new ClientMetadata(mimeType), FreenetURI.EMPTY_CHK_URI);

              startTime = System.currentTimeMillis();
              FreenetURI uri = client.insert(block, getCHKOnly, f.getName());
             
View Full Code Here

    //   Skip files nonexistant (dangling symlinks) - check last
          if (filelist[i].canRead() && filelist[i].exists()) {     
        if (filelist[i].isFile()) {
          File f = filelist[i];
         
          FileBucket bucket = new FileBucket(f, true, false, false, false);
         
          ret.put(f.getName(), bucket);
        } else if(filelist[i].isDirectory()) {
          HashMap<String, Object> subdir = makeBucketsByName(directory + filelist[i].getName());
          ret.put(filelist[i].getName(), subdir);
View Full Code Here

   
    String path = uri.getPath();
    if(path.endsWith(NodeUpdateManager.WINDOWS_FILENAME)) {
      File installer = node.nodeUpdater.getInstallerWindows();
      if(installer != null) {
        FileBucket bucket = new FileBucket(installer, true, false, false, false);
        this.writeReply(ctx, 200, "application/x-msdownload", "OK", bucket);
        return;
      }
    }
   
    if(path.endsWith(NodeUpdateManager.NON_WINDOWS_FILENAME)) {
      File installer = node.nodeUpdater.getInstallerNonWindows();
      if(installer != null) {
        FileBucket bucket = new FileBucket(installer, true, false, false, false);
        this.writeReply(ctx, 200, "application/x-java-archive", "OK", bucket);
        return;
      }
    }
   
View Full Code Here

              filename = request.getPartAsStringFailsafe("filename", QueueToadlet.MAX_FILENAME_LENGTH);
              if (mimeType.length() == 0) {
                  mimeType = DefaultMIMETypes.guessMIMEType(filename, false);
              }
              File file = new File(filename);
              bucket = new FileBucket(file, true, false, false, false);
            } else {
                HTTPUploadedFile file = request.getUploadedFile("filename");
                if (file == null) {
                    throw new BadRequestException("filename");
                }
View Full Code Here

    public static void main(String arg[]) throws Throwable {
        final File fin = new File("/tmp/test.css");
        final File fout = new File("/tmp/test2.css");
        fout.delete();
        final Bucket inputBucket = new FileBucket(fin, true, false, false, false);
        final Bucket outputBucket = new FileBucket(fout, false, true, false, false);
        InputStream inputStream = null;
        OutputStream outputStream = null;
        try {
            inputStream = inputBucket.getInputStream();
            outputStream = outputBucket.getOutputStream();
            Logger.setupStdoutLogging(Logger.LogLevel.DEBUG, "");

            ContentFilter.filter(inputStream, outputStream, "text/css",
                    new URI("http://127.0.0.1:8888/freenet:USK@ZupQjDFZSc3I4orBpl1iTEAPZKo2733RxCUbZ2Q7iH0,EO8Tuf8SP3lnDjQdAPdCM2ve2RaUEN8m-hod3tQ5oQE,AQACAAE/jFreesite/19/Style/"), null, null, null);
        } finally {
            Closer.close(inputStream);
            Closer.close(outputStream);
            inputBucket.free();
            outputBucket.free();
        }
    }
View Full Code Here

      if((!from.exists()) && (!from.isFile())) {
        this.sendErrorPage(ctx, 404, l10n("pathNotFoundTitle"), l10n("pathInvalidChars"));
        return;
      }
      try {
        FileBucket fb = new FileBucket(from, true, false, false, false);
        ctx.sendReplyHeadersStatic(200, "OK", null, DefaultMIMETypes.guessMIMEType(path, false), fb.size(), new Date(System.currentTimeMillis() - 1000)); // Already expired, we want it to reload it.
        ctx.writeData(fb);
        return;
      } catch (IOException e) {
        // Not strictly accurate but close enough
        this.sendErrorPage(ctx, 404, l10n("pathNotFoundTitle"), l10n("pathNotFound"));
View Full Code Here

TOP

Related Classes of freenet.support.io.FileBucket

Copyright © 2018 www.massapicom. 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.