@Override
  public InputFile toInputFile() {
    return new OSSInputFile(client(), uri(), aliyunProperties(), metrics());
  }
@Test
  public void testToInputFile() throws IOException {
    int dataSize = 1024 * 10;
    byte[] data = randomData(dataSize);

    OutputFile out =
        new OSSOutputFile(ossClient, randomURI(), aliyunProperties, MetricsContext.nullMetrics());
    try (OutputStream os = out.create();
        InputStream is = new ByteArrayInputStream(data)) {
      ByteStreams.copy(is, os);
    }

    InputFile in = out.toInputFile();
    assertThat(in).as("Should be an instance of OSSInputFile").isInstanceOf(OSSInputFile.class);
    assertThat(in.exists()).as("OSS file should exist").isTrue();
    assertThat(in.location()).as("Should have expected location").isEqualTo(out.location());
    assertThat(in.getLength()).as("Should have expected length").isEqualTo(dataSize);

    byte[] actual = new byte[dataSize];
    try (InputStream as = in.newStream()) {
      ByteStreams.readFully(as, actual);
    }
    assertThat(actual).as("Should have expected content").isEqualTo(data);
  }