code: public void putContentStream(MIMETypedStream stream) throws StreamIOException {
  
          // TODO: refactor to use proper temp file management - FCREPO-718
          // for now, write to new temp file, clean up existing location
          String oldDSLocation = DSLocation;
          try {
              // note: don't use temp upload dir, use (container's) temp dir (upload dir is for uploads)
              File tempFile = File.createTempFile("managedcontentupdate", null);
              OutputStream os = new FileOutputStream(tempFile);
              StreamUtility.pipeStream(stream.getStream(), os, 32768);
              DSLocation = TEMP_SCHEME + tempFile.getAbsolutePath();
          } catch (Exception e) {
              throw new StreamIOException("Error creating new temp file for updated managed content (existing content is:" + oldDSLocation + ")", e);
          }
  
          // if old location was a temp location, clean it up
          // (if old location was uploaded, DefaultManagement should do this, but refactor up as part of FCREPO-718)
          if (oldDSLocation != null && oldDSLocation.startsWith(TEMP_SCHEME)) {
              File oldFile;
              try {
                  oldFile = new File(oldDSLocation.substring(TEMP_SCHEME.length()));
              } catch (Exception e) {
                  throw new StreamIOException("Error removing old temp file while updating managed content (location: " + oldDSLocation + ")", e);
              }
              if (oldFile.exists()) {
                  if (!oldFile.delete()) {
                      logger.warn("Failed to delete temp file, marked for deletion when VM closes " + oldFile.getAbsolutePath());
                      oldFile.deleteOnExit();
                  }
              } else
                  logger.warn("Cannot delete temp file as it no longer exists " + oldFile.getAbsolutePath());
          }
      }
docs: Set the contents of this managed datastream by storing as a temp file.  If the previous content
  was stored in a temp file, clean up this file.
  @param stream - the data to store in this datastream
  @throws StreamIOException